matlab ---结构数组

结构数组的创建

  • 使用点号(.) 运算符创建
>> patient.name='John Doe'

patient = 

    name: 'John Doe'

>> patient.billing=127

patient = 

       name: 'John Doe'
    billing: 127 
>> patient.test=[79,75,73;80,78,75;77,76,86]

patient = 

       name: 'John Doe'
    billing: 127
       test: [3x3 double]

>> patient.test

ans =

    79    75    73
    80    78    75
    77    76    86
  • 利用struct 函数创建结构数组,该函数的调用形式为:
    s=struct(‘field1’,value1,’field2’,value2)
>> patient=struct('name','John Doe','hilling','127')

patient = 

    name: 'John Doe'
    hilling: '127'

>> patient=struct('name','John Doe','hilling','127','test',patient)

patient = 

       name: 'John Doe'
    hilling: '127'
       test: [1x1 struct]

>> patient=struct('name','John Doe','hilling','127','test',patient.test)

patient = 

       name: 'John Doe'
    hilling: '127'
       test: [1x1 struct]
>> S.a='CHINA';S.b='JAPAN'

S = 

    a: 'CHINA'
    b: 'JAPAN'

你可能感兴趣的:(matlab)