Looping over inputs provided by structure
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!