Line | |
---|
1 | function F = replace(F,X,W) |
---|
2 | %REPLACE Substitutes variables in a SET object |
---|
3 | % |
---|
4 | %Z = REPLACE(F,X,W) Replaces any occurence of the SDPVAR object Y |
---|
5 | % in the SDPVAR object X with the double W |
---|
6 | % |
---|
7 | % Example |
---|
8 | % x = sdpvar(1,1); |
---|
9 | % t = sdpvar(1,1); |
---|
10 | % F = set([1+t;1+x+t] > 0); |
---|
11 | % F = replace(F,x,2) generates F=set([1+t;3+t] > 0) |
---|
12 | |
---|
13 | if prod(size(W)) == 1 |
---|
14 | W = repmat(W,size(X)); |
---|
15 | end |
---|
16 | |
---|
17 | keep = []; |
---|
18 | |
---|
19 | for i = 1:length(F.clauses) |
---|
20 | F.clauses{i}.data = replace(F.clauses{i}.data,X,W); |
---|
21 | if isempty(F.clauses{i}.data) | isa(F.clauses{i}.data,'double') |
---|
22 | keep(i)=0; |
---|
23 | else |
---|
24 | keep(i)=1; |
---|
25 | end |
---|
26 | end |
---|
27 | |
---|
28 | F.clauses = {F.clauses{find(keep)}}; |
---|
29 | |
---|
30 | % Get new identifiers |
---|
31 | F.LMIid = []; |
---|
32 | for i = 1:length(F.clauses) |
---|
33 | F.LMIid = [F.LMIid yalmip('lmiid')]; |
---|
34 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.