Help on creating an cell array

조회 수: 3 (최근 30일)
Steven
Steven 2013년 7월 28일
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.

채택된 답변

Azzi Abdelmalek
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
  댓글 수: 1
Steven
Steven 2013년 7월 28일
Thank you very much! Those examples were very helpful.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by