Help on creating an cell array
1 次查看(过去 30 天)
显示 更早的评论
I am trying to create an cell array that will show names and ages of each person. I do not know how to begin with structuring this.
0 个评论
采纳的回答
Azzi Abdelmalek
2013-7-28
编辑:Azzi Abdelmalek
2013-7-28
A={'Name' 'Age';'Mick' 70;'Jhon' 80}
%or
header={'name' 'age'}
names={'Mick';'Jhon';'Ana'}
ages={70;80;20}
Yourcell=[header;[names ages]]
% Or you can also use a struct array
v=struct('name',{'Mick','Jhon','Ana'},'Age',{70 80 20})
% If you want to access to each element:
%first person
v(1).name
v(1).Age
%second person
v(2).name
v(2).Age
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!