Looping over inputs provided by structure
显示 更早的评论
the Structure Setup
AppleDataGreen = struct('taste','Sour', 'color','Bright')
AppleDataRed = struct('taste','Sweet', 'color','Bright')
apples = struct( 'AppleType' ...
, struct('Green',struct(AppleDataGreen) ...
,'Red', struct(AppleDataRed)) )
I have a code that I want to run the data in the green structure and then run the Red structure
From matlab I was trying to us a for loop by doing this
% this takes me to the green and red structure giving me a
% length 2 hopefully
for i=1:length(apples.AppleType)
run(apples.AppleType{i})
code
end
error cell contents reference from a non-cell array object
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!