-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsplitPiecewise.m
More file actions
29 lines (19 loc) · 915 Bytes
/
splitPiecewise.m
File metadata and controls
29 lines (19 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function [lowerConstraints, upperConstraints] = splitPiecewise(oldConstraints, splitPoint, invalidMonthIndex)
lowerConstraints = {};
upperConstraints = {};
for constraint = 1:2
for month=1:length({oldConstraints{constraint,:}})
if(month == invalidMonthIndex)
belowSplit = oldConstraints{constraint,month}(1,:) <= splitPoint(1);
aboveSplit = ~belowSplit;
lower = oldConstraints{constraint, month}(:,belowSplit);
upper = oldConstraints{constraint, month}(:,aboveSplit);
lowerConstraints{constraint, month} = [lower splitPoint'];
upperConstraints{constraint, month} = [splitPoint' upper];
else
lowerConstraints{constraint, month} = oldConstraints{constraint, month};
upperConstraints{constraint, month} = oldConstraints{constraint, month};
end
end
end
end