MATLAB Object-Oriented Programming

(Joyce) #1

This subscripted reference returns a comma-separated list of three elements. For this
statement, the value of nargout in subsref is 3.


l(1:3).Values


ans =


1


ans =


2


ans =


3


The left side of a subscripted assignment statement affects the number of input
arguments that MATLAB uses to call subsasgn. This subscripted assignment assigns
three values to the three elements added to the array. For this assignment, the value of
nargin within subsasgn is 5 (the object, the indexing substructure, and the three values
to assign).


[l(11:13).Values] = l(1:3).Values


l =


1x13 ValuesArray array with properties:


Values


If the number of right-side arguments cannot satisfy the number of left-side arguments,
MATLAB returns an error:


[l(11:13).Values] = l(1).Values


Insufficient number of outputs from right hand side of equal sign to satisfy
assignment.


Number of Arguments for subsref and subsasgn
Free download pdf