|
56 | 56 | %% @seealso{@@sym/subsref, @@sym/subindex, @@sym/end, symfun} |
57 | 57 | %% @end deftypeop |
58 | 58 |
|
| 59 | + |
59 | 60 | function out = subsasgn (val, idx, rhs) |
60 | 61 |
|
61 | 62 | switch idx.type |
|
76 | 77 | all_Symbols = python_cmd (cmd, idx.subs); |
77 | 78 | end |
78 | 79 | if (all_syms && all_Symbols) |
79 | | - %% Make a symfun |
| 80 | + %% Make a symfun |
80 | 81 | if (~isa(rhs, 'sym')) |
81 | 82 | % rhs is, e.g., a double, then we call the constructor |
82 | 83 | rhs = sym(rhs); |
|
91 | 92 | idx.subs{i} = double(idx.subs{i}); |
92 | 93 | end |
93 | 94 | end |
94 | | - for i = 1:length(idx.subs) |
| 95 | + for i = 1:length(idx.subs) |
95 | 96 | if (~ is_valid_index(idx.subs{i})) |
96 | 97 | error('OctSymPy:subsref:invalidIndices', ... |
97 | 98 | 'invalid indices: should be integers or boolean'); |
98 | 99 | end |
99 | | - end |
| 100 | + end |
100 | 101 | out = mat_replace(val, idx.subs, sym(rhs)); |
101 | 102 | end |
102 | 103 |
|
|
162 | 163 | %! b([1 end+1],end:end+1) = rhs; |
163 | 164 | %! assert(isequal( a, b )) |
164 | 165 |
|
| 166 | +%!test |
| 167 | +%! % grow from nothing |
| 168 | +%! clear a |
| 169 | +%! a(3) = sym (1); |
| 170 | +%! b = sym ([0 0 1]); |
| 171 | +%! assert (isequal (a, b)) |
| 172 | + |
| 173 | +%!test |
| 174 | +%! % grow from nothing, 2D |
| 175 | +%! clear a |
| 176 | +%! a(2, 3) = sym (1); |
| 177 | +%! b = sym ([0 0 0; 0 0 1;]); |
| 178 | +%! assert (isequal (a, b)) |
| 179 | + |
165 | 180 | %!test |
166 | 181 | %! % linear indices of 2D |
167 | 182 | %! b = 1:4; b = [b; 2*b; 3*b]; |
|
0 commit comments