How to read a structure array

조회 수: 4 (최근 30일)
Ocram
Ocram 2012년 3월 29일
Hi everybody, I'm trying to insert a structure array inside a for loop in order to allow the reading of each fiel automatically, by linking an index to the structure field. Is this possible or I can only access it by indicating the name of the field?
Thank, M
  댓글 수: 1
Jan
Jan 2012년 3월 29일
It is always a good idea to post the currently existing code.

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

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2012년 3월 29일
pg
Mstruct = struct('a','gfjgfjf','b',[4 5 6],'c',{{7 8 9}})
nfield = fieldnames(Mstruct)
for j1 = 1:numel(nfield),disp(Mstruct.(nfield{j1}));end

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by