We have moved to @ Placement Papers Hub !! Visit our new website here for more..

Creating a Structure, an Array of Structures and Writing Commands to Access Elements of the created Structure and Array of Structures


Creating a Structure, an Array of Structures and Writing Commands to Access Elements of the created Structure and Array of Structures

>> S.id=12;
>> S.name='raj';
>> S.city='hyd';
>> disp(S);

      id: 12
    name: 'raj'
    city: 'hyd'


>> S=struct('rid',11,'name','vamshi','city','hyd');
>> S.name

ans =
vamshi

>> S.rid

ans =
    11

>> S.city

ans =
hyd



>> S=struct('rid',{11,12},'name',{'vamshi','sandeep'},'city',{'hyd','sura'});

>> S(1).name
ans =
vamshi

>> S(2).name
ans =
sandeep

>> S(1).rid
Ans=
11
>> S(2).rid
ans =
    12

>> S(1).city
ans =
hyd

>> S(2).city
ans =
surat


>> S(1)
ans =
     rid: 11
    name: 'vamshi'
    city: 'hyd'

>> S(2)
ans =
     rid: 12
    name: 'sandeep'
    city: 'sura'