|||
There are two ways to refer to the elements of a cell array:
Enclose indices in smooth parentheses, (), to refer to sets of cells—for example, to define a subset of the array;
Enclose indices in curly braces, {}, to refer to the text, numbers, or other data within individual cells.
Curly braces are used in cell array assignment statements.
>>> C={'one', 'two', 'three'; 1, 2, 3}; % C 2X3 cell
C=
'one' 'two' 'three'
[ 1] [ 2] [ 3]
>>> C(1,2)
ans=
'two' % ans 1X1 cell
>>> C{2,1}
ans=
1 % ans is a number
>>> C{1,2}
ans=
'two' % ans str
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-6-26 06:51
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社