Can an entire structure be iterated in a loop?
3 views (last 30 days)
Show older comments
Zachary Pinz
on 21 Jul 2017
Commented: Zachary Pinz
on 21 Jul 2017
I have a function that outputs a structure. I need to run this function through a series of iterations. Is it possible to iterate the entire output structure as shown below? I would like to save the structure after running through the loop as well. The code operates as follows:
for a = 1:100
for b = 1:100
% input changes per iteration
structure(a,b) = function(input);
end
end
save('path\to\destination\folder','-struct','structure');
0 Comments
Accepted Answer
Image Analyst
on 21 Jul 2017
Edited: Image Analyst
on 21 Jul 2017
Looks right to me, assuming you aren't actually using the exact names function, input, and structure. You shouldn't need the '-struct' option in save though. Did you try it and have a problem?
More Answers (0)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!