source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/extras/@lmi/subsasgn.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.9 KB
Line 
1function F0 = subsasgn(F,Y,Z)
2%subasgn           Overloaded indexing
3
4% Author Johan Löfberg
5% $Id: subsasgn.m,v 1.4 2005/04/29 16:28:03 joloef Exp $   
6
7% TODO : Implement lmi/subsasgn...
8%error('set/subsasgn not fully implemented yet. Contact author if you need this functionality')
9switch Y(1).type
10    case '()'
11        thelmi = Y.subs{1};
12       
13        if ~isa(F,'lmi')
14            error('First argument should be a SET object')
15        end
16       
17        if ~(isa(thelmi,'double') | isa(thelmi,'char'))
18            error('Index should be an integer integer or tag-string')
19        end
20       
21        if ~(isa(Z,'lmi') | isempty(Z))
22            error('Right-hand side should be a SET object or empty');
23        end
24       
25        % If indexed using handle, convert to index
26        if isa(thelmi,'char')
27            thelmitemp = [];
28            for i = 1:size(F.clauses,2)
29                if strcmp(F.clauses{i}.handle,thelmi)
30                    thelmitemp=[thelmitemp i];
31                end
32            end
33            if isempty(thelmitemp)
34                em = ['LMI ''' thelmi ''' not available.'];
35                error(em)
36            else
37                thelmi = thelmitemp;
38            end
39        end
40       
41        % Convert to linear indecicies
42        if islogical(thelmi)
43           thelmi = double(find(thelmi));
44        end
45       
46        % Checks so that it exist
47        if any((thelmi<1)) | any((thelmi>size(F.clauses,2)))
48            em = ['LMI #' num2str(thelmi(find(thelmi>size(F.clauses,2)))) ' not available.'];
49            error(em)
50        end
51       
52        F0 = F;
53       
54        % Specialized for deleting constraints
55        if isempty(Z)
56            F0.clauses = {F0.clauses{setdiff(1:size(F.clauses,2),thelmi)}};
57            F0.LMIid = F0.LMIid(setdiff(1:size(F.clauses,2),thelmi));
58        else
59            if length(thelmi) < length(Z.clauses)
60                error('???  In an assignment  A(I) = B, the number of elements in B and I must be the same.');
61            end
62            for i = 1:length(thelmi)
63                F0.clauses{thelmi(i)} = Z.clauses{i};
64                F0.LMIid(thelmi(i)) = Z.LMIid(i);
65            end
66        end
67       
68    case '{}'
69        switch length(Y)
70            case 1
71                if length(Y.subs)>1
72                    error('Only one-dimensional indexing of set objects allowed'); 
73                end
74                if Y.subs{1}>length(F.clauses)
75                    em = ['LMI #' num2str(Y.subs{1}) ' not available.'];
76                error(em)
77                    error('Index exceeds set dimension.')
78                end               
79                F0 = F.clauses{Y.subs{1}}.data;               
80            case 2
81                F0 = F.clauses{Y(1).subs{1}}.data;
82                F0 = subsref(F0,Y(2));
83            otherwise
84                error('Indexing type not supported');   
85        end
86    otherwise
87        error('Indexing type not supported');       
88end
89
90
91
Note: See TracBrowser for help on using the repository browser.