I have a question please if we have structure with 3 dimension and each field of them has 7 values how can extract each value from each field of this structure separately.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Just use indexing:
>> s(1,1,1).data = [1 2 3 4];
>> s(1,1,2).data = [10 20 30 40 50]; %// example struct
>> s(1,1,2).data(3)
ans =
30
>> s(1,1,2).data(2:4)
ans =
20 30 40
Also, it's better not to use struct
as a variable name, because struct
is a built-in function.