How to create a new figure in MATLAB?

Viewed 247015

Usually when I plot in MATLAB, it always draws on the same figure. How do I make it draw in a new figure?

I know it is pretty elementary, but I'm not finding it using Google Search.

6 Answers
figure;
plot(something);

or

figure(2);
plot(something);
...
figure(3);
plot(something else);
...

etc.

The other thing to be careful about, is to use the clf (clear figure) command when you are starting a fresh plot. Otherwise you may be plotting on a pre-existing figure (not possible with the figure command by itself, but if you do figure(2) there may already be a figure #2), with more than one axis, or an axis that is placed kinda funny. Use clf to ensure that you're starting from scratch:

figure(N);
clf;
plot(something);
...
Related