How can the output of a order character string stored in a variable?

조회 수: 1 (최근 30일)
xosro
xosro 2015년 7월 16일
댓글: xosro 2015년 7월 16일
i have a structure variable contain several field, i wish insert once of fields that dispaly of this field is Character to form string in another variable. for example : A(1).name='walter'; A(2).name='xosro'; A(1).rank=1; A(2).rank=10; i wish have : names=cell(2,1); names=A(1:2).name; that

채택된 답변

Titus Edelhofer
Titus Edelhofer 2015년 7월 16일
Hi xosro,
I'm not sure if this is what you want, but
names = {A(1:2).name}
collects the names into a cell array (or {A.names} if you want all).
Titus
  댓글 수: 2
Titus Edelhofer
Titus Edelhofer 2015년 7월 16일
And btw, if you want to collect the ranks, since they are numbers, you can create an array simply by
ranks = [A.rank];
If you want to read more about this, look into the doc for "comma separated lists".
Titus
xosro
xosro 2015년 7월 16일
hi Titus thank you ya that is my target I am confused,i try this code ,i do not know give error? but now ...

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Quantum Mechanics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by