how do I define an index for the subplot position from two indexes of nested for loops?
Show older comments
I have a nested for loop that looks like such:
for i=1:length(input1)
for j=1:length(input2)
[x,y]=function(input1(i),input2(j))
end
end
but for each iteration of the nested for loop I would like to plot x vs. y in a subplot of dimensions i by j
so I am trying to update my code to look something like:
for i=1:length(input1)
for j=1:length(input2)
[x,y]=function(input1(i),input2(j))
k = ??? I can't figure out how to define this index...
subplot(length(i),length(j),k)
end
end
what is the right way to define an index, k, so that as the nested for loop runs it will subplot x vs. y in the correct position of a i by j dimensional subplot that corresponds to the current values of i and j ??
any help is greatly appreciated!! :)
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!