Help on creating an cell array

1 visualización (últimos 30 días)
Steven
Steven el 28 de Jul. de 2013
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.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 28 de Jul. de 2013
Editada: Azzi Abdelmalek el 28 de Jul. de 2013
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 comentario
Steven
Steven el 28 de Jul. de 2013
Thank you very much! Those examples were very helpful.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Function Creation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by