How to read a structure array

3 次查看(过去 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