Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


dpb
Posts:
8,982
Registered:
6/7/07


Re: Increment figure number in 3 dimensional loop
Posted:
Jan 23, 2013 12:59 PM


On 1/23/2013 11:49 AM, Phil Roberts wrote: > "Steven_Lord" <slord@mathworks.com> wrote in message > <kdp5vv$oua$1@newscl01ah.mathworks.com>... >> "Phil Roberts" <harsh_classic@yahoo.co.uk> wrote in message >> news:kdp2hs$a67$1@newscl01ah.mathworks.com... ...
>> > How can I increment the figures so that 16 are shown i.e. 8 from the >> 1st > "k" loop and 8 from the 2nd "k" loop? >> >> Your figure number needs to depend upon both j AND k. If you don't >> care about having figures 116 you could just use 8*k+j to open >> figures 9 through 24. ... > I would like to understand how I go about opening 16 individual figures > (8 from the first "k" loop and 8 from the second "k" loop). Once I have > done this I will have a look at the subplot function. > > Therefore, how would I go about editing my code? ...
A trivial way is to add a counter for the figure... fig=0; % Initialize for k = 1:2 for j = 1:8; f=f+1; figure(f) ... end end
Or, even more simply, Matlab will automagically open a new figure
for k = 1:2 for j = 1:8; figure ... end end
As Steven showed you can compute the figure number for a given k,j combination algebraically if needed (assuming start w/ none open alreadyif so, add the offset or clear 'em out)




