1 | function sys = dellmi(F,thelmi) |
---|
2 | %dellmi (OBSOLETE) Deletes a constraint in an LMI object |
---|
3 | % |
---|
4 | % F = DELLMI(F,n) Delete the n'th LMIs |
---|
5 | % F = DELLMI(F,'tag') Delete the LMIs having specified tag |
---|
6 | % |
---|
7 | % See also LMI, UPDATELMI |
---|
8 | |
---|
9 | |
---|
10 | % Author Johan Löfberg |
---|
11 | % $Id: dellmi.m,v 1.3 2005/02/04 10:10:26 johanl Exp $ |
---|
12 | |
---|
13 | if nargin ~=2 |
---|
14 | error('DELLMI needs two argument') |
---|
15 | end |
---|
16 | |
---|
17 | if ~(isa(F,'lmi') & (isa(thelmi,'double') | isa(thelmi,'char'))) |
---|
18 | error('First argument should be an lmi object and second argument integer or string') |
---|
19 | end |
---|
20 | |
---|
21 | % If indexed using handle, convert to index |
---|
22 | if isa(thelmi,'char') |
---|
23 | thelmitemp = []; |
---|
24 | for i = 1:size(F.clauses,2) |
---|
25 | if strcmp(F.clauses{i}.handle,thelmi) |
---|
26 | thelmitemp=[thelmitemp i]; |
---|
27 | end |
---|
28 | end |
---|
29 | if isempty(thelmitemp) |
---|
30 | em = ['LMI ''' thelmi ''' not available.']; |
---|
31 | error(em) |
---|
32 | else |
---|
33 | thelmi = thelmitemp; |
---|
34 | end |
---|
35 | end |
---|
36 | |
---|
37 | % Checks so that it exist |
---|
38 | if any((thelmi<1)) | any((thelmi>size(F.clauses,2))) |
---|
39 | em = ['LMI #' num2str(thelmi) ' not available.']; |
---|
40 | error(em) |
---|
41 | end |
---|
42 | sys = F; |
---|
43 | del_lmi = thelmi(logical(thelmi<=size(F.clauses,2))); |
---|
44 | if ~isempty(del_lmi) |
---|
45 | keep_lmi = setdiff(1:size(F.clauses,2),del_lmi); |
---|
46 | sys.clauses = {F.clauses{keep_lmi}}; |
---|
47 | sys.LMIid = sys.LMIid(keep_lmi); |
---|
48 | end |
---|