I have a large for loop that produces a lot of graphs. I'm adding functionality to the code and would like to have the option to toggle between putting a series of graphs into a one figure with subplots, or plotting the graphs as individual figures. I tried to do this using the following code, but it doesn't work.

figure
if (SubplotOPT == 0)
subplot(2,2,1);
end

The idea is that if the SubplotOPT == 0 is not satisfied then the code will produce a individual figure, however, I think matlab is making a subplot regardless of the if statement.

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

but not work, can you elaborate? What happens instead? It sounds like you see a "subplotted" figure when you don't expect it. Also, can you give a little more background in the code, before and after?
–
macduffFeb 26 '13 at 23:23

I figured it out just a minute ago. The code above produces a subplot of the position indepedent of the loop. figure if (SubplotOPT == 0) subplot(2,2,1); else subplot(1,1,1) end
–
Grady F. Mathews IvFeb 26 '13 at 23:25