单元数组

单元数组使用花括号来创建
>> a{1,1} = 'cell';
>> a{1,2} = [1 2 3];
>> b = {'Jan'};
>> c = {a b};
>> whos
  Name      Size            Bytes  Class    Attributes

  a         1x2               256  cell               
  b         1x1               118  cell               
  c         1x2               598  cell   


对于单元数组C, C(m,n)指的是单元数组中第m行第n列的单元,而C{m,n}指的是单元数组中第m行第n列单元中的内容

>> C = {3,[4 7;6 6;80 9],'string';sin(pi/8),3>10,'code'}
unitVal_1 = C(2,2)
class(unitVal_1)
unitVal_2 = C{2,2}
class(unitVal_2)

C = 

    [                3]    [3x2 double]    'string'
    [0.382683432365090]    [         0]    'code'  


unitVal_1 = 

    [0]


ans =

cell


unitVal_2 =

     0


ans =

logical


你可能感兴趣的:(单元数组)