[37] | 1 | function sys = updatelmi(F,thelmi) |
---|
| 2 | %updatelmi (OBSOLETE) Updates the numerical content of a symbolic LMI |
---|
| 3 | % |
---|
| 4 | % F = UPDATELMI(F,n) Updates the n'th symbolic LMIs |
---|
| 5 | % F = UPDATELMI(F,'tag') Updates the symbolic LMIs having specified tag |
---|
| 6 | % |
---|
| 7 | % See also LMI, DELLMI |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | % Author Johan Löfberg |
---|
| 11 | % $Id: updatelmi.m,v 1.2 2004/07/19 13:54:37 johanl Exp $ |
---|
| 12 | |
---|
| 13 | error('updatelmi is obsolete'); |
---|
| 14 | |
---|
| 15 | if nargin ~=2 |
---|
| 16 | error('UPPDATELMI needs two argument') |
---|
| 17 | end |
---|
| 18 | |
---|
| 19 | if ~(isa(F,'lmi') & (isa(thelmi,'double') | isa(thelmi,'char'))) |
---|
| 20 | error('First argument should be an lmi object and second argument integer or string') |
---|
| 21 | end |
---|
| 22 | |
---|
| 23 | % If indexed using handle, convert to index |
---|
| 24 | if isa(thelmi,'char') |
---|
| 25 | thelmitemp = []; |
---|
| 26 | for i = 1:size(F.AllConstraints,2) |
---|
| 27 | if strcmp(F.AllConstraints{i}.handle,thelmi) |
---|
| 28 | thelmitemp=[thelmitemp i]; |
---|
| 29 | end |
---|
| 30 | end |
---|
| 31 | % for i = 1:size(F.Equalities,2) |
---|
| 32 | % if strcmp(F.Equalities{i}.handle,thelmi) |
---|
| 33 | % thelmitemp=[thelmitemp i+size(F.AllConstraints,2)]; |
---|
| 34 | % end |
---|
| 35 | % end |
---|
| 36 | if isempty(thelmitemp) |
---|
| 37 | em = ['LMI ''' thelmi ''' not available.']; |
---|
| 38 | error(em) |
---|
| 39 | else |
---|
| 40 | thelmi = thelmitemp; |
---|
| 41 | end |
---|
| 42 | end |
---|
| 43 | |
---|
| 44 | % Checks so that it exist |
---|
| 45 | if any((thelmi<1)) | any((thelmi>size(F.AllConstraints,2))) |
---|
| 46 | em = ['LMI #' num2str(thelmi) ' not available.']; |
---|
| 47 | error(em) |
---|
| 48 | end |
---|
| 49 | |
---|
| 50 | for j = 1:length(thelmi) |
---|
| 51 | nlmi = thelmi(j); |
---|
| 52 | % Get the old symbolic expression |
---|
| 53 | if (nlmi>size(F.AllConstraints,2)) |
---|
| 54 | % An equality constraint |
---|
| 55 | nlmi = nlmi-size(F.AllConstraints,2); |
---|
| 56 | X = F.Equalities{nlmi}.symbolic; |
---|
| 57 | eq = 1; |
---|
| 58 | else |
---|
| 59 | % LMI |
---|
| 60 | X = F.AllConstraints{nlmi}.symbolic; |
---|
| 61 | eq = 0; |
---|
| 62 | end |
---|
| 63 | |
---|
| 64 | % Check for symbolic value |
---|
| 65 | if strcmpi('Numeric value',X) |
---|
| 66 | error('Numeric LMIs cannot be updated'); |
---|
| 67 | end |
---|
| 68 | |
---|
| 69 | % Parse the LMI |
---|
| 70 | sdpvarExpr = parseLMI(X); |
---|
| 71 | X = strrep(X,'.>','>'); |
---|
| 72 | X = strrep(X,'.<','<'); |
---|
| 73 | X = strrep(X,'=','==');X = strrep(X,'====','=='); |
---|
| 74 | try |
---|
| 75 | Fi=evalin('caller',sdpvarExpr); |
---|
| 76 | catch |
---|
| 77 | error(lasterr) |
---|
| 78 | end |
---|
| 79 | |
---|
| 80 | TypeofConstraint = gethackflag(Fi); |
---|
| 81 | % User just sent a sdpvar object, interpret as X>0 |
---|
| 82 | if (TypeofConstraint==0) |
---|
| 83 | TypeofConstraint = 1; |
---|
| 84 | end |
---|
| 85 | |
---|
| 86 | % check so that LMIs are symmetric |
---|
| 87 | if (TypeofConstraint == 1) |
---|
| 88 | [n,m]=size(Fi); |
---|
| 89 | if (n~=m) | (~issymmetric(Fi)) |(n*m==1) |
---|
| 90 | TypeofConstraint = 2; %Change to elementwise |
---|
| 91 | end |
---|
| 92 | end |
---|
| 93 | |
---|
| 94 | % Check the normbound |
---|
| 95 | if (TypeofConstraint == 4) |
---|
| 96 | [n,m]=size(Fi); |
---|
| 97 | if m~=1 |
---|
| 98 | error('Norm ||..|| must look like || vector ||< scalar, or scalar>|| vector ||') |
---|
| 99 | end |
---|
| 100 | end |
---|
| 101 | |
---|
| 102 | sys=F; |
---|
| 103 | switch TypeofConstraint |
---|
| 104 | case {1,2,3,4} |
---|
| 105 | sys.AllConstraints{nlmi}.data=Fi; |
---|
| 106 | sys.AllConstraints{nlmi}.type = TypeofConstraint; |
---|
| 107 | sys.AllConstraints{nlmi}.symbolic=X; |
---|
| 108 | otherwise |
---|
| 109 | error('Error in argument.'); |
---|
| 110 | end |
---|
| 111 | end; |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | |
---|