Structures in Matlab

In MATLAB you cannot create an array that is a direct analog to an range which can contain mixed data types. In MATLAB you cannot do the following:

Example

>> my.birthday = 1986

my = 

    birthday: 1986

>> my.class = 'MS'

my = 

    birthday: 1986
       class: 'MS'

>> my.university = 'cornell'

my = 

      birthday: 1986
         class: 'MS'
    university: 'cornell'

In the above example my will be a structure with some properties.

Another structure define way with struct keyword

>> my1 = struct('birthday',1986,'class','MS','university','cornell')

my1 = 

      birthday: 1986
         class: 'MS'
    university: 'cornell'

Structures values accessed as :

Example

>> my1.birthday

ans =

        1986

>> my.class

ans =

MS

>> my.birthday

ans =

        1986

>> my.university

ans =

cornell

>> my.class

ans =

MS