SUBSASGN
From Jacket Wiki
Back to Function List
Subscripted assignment
Usage
| Jacket for M Language | |||||||||||
| Supported Syntax | |||||||||||
A = subsasgn(A,S,B) A(A > .5) = a A(1:5) = a A(1:5) = 0 A(1:5) = 1:5 A(2,3) = NaN A(idx) = [] % where idx is sorted |
|||||||||||
|
|||||||||||
Notes
Known issue: subscript assignment using a boolean mask and CPU scalar into a field or cell array results in a double-free within the MATLAB runtime. The work around is to cast the CPU scalar to gsingle()
A.field(A.field > .5) = 4; % will fail A.field(A.field > .5) = gsingle(4); % will work
- A = subsasgn(A,S,B) is called internally by MATLAB for the syntax A(i) = B(i), A{i} = B, or A.i = B
>> A = grand(4) A = 0.6206 0.8232 0.7425 0.7810 0.5977 0.6119 0.1391 0.0675 0.0493 0.4752 0.0558 0.4507 0.5730 0.0074 0.5251 0.4150 >> A(1:3,2:4) = 7.7777 A = 0.6206 7.7777 7.7777 7.7777 0.5977 7.7777 7.7777 7.7777 0.0493 7.7777 7.7777 7.7777 0.5730 0.0074 0.5251 0.4150
- See Torben's Corner notes on SUBSASGN (Matrix).