S contains:
S.type = '()'
S.subs = {2,3}
The built-in subsasgn:
- Determines the class of A. If B is not the same class as A, then MATLAB tries to
construct an object of the same class as A using B as an input argument. If this
attempt fails, MATLAB returns an error. - If A and B are, or can be made, into the same class, then MATLAB assigns the value of
B to the array element at row 2 , column 3. - If A does not exist before you execute the assignment statement, then MATLAB
initializes the five array elements that come before A(2,3) with default objects of
class B.
Similarly, this expression
A{2,3} = B
Uses these values for S:
S.type ='{}'
S.subs = {2,3}
The built-in subsasgn:
- Assigns B to the cell array element at row 2 , column 3.
- If A does not exist before you execute the assignment statement, MATLAB initializes
the five cells that come before A(2,3) with []. The result is a 2-by-3 cell array.
This expression:
A.Name = B
Calls A = subsasgn(A,S,B) where the struct S has these values:
S.type = '.'
S.subs = 'Name'
The built-in subsasgn:
- Assigns B to the struct field Name.
17 Specialize Object Behavior