5

i'm writting some code in Matlab editor, which has about 30 figures. So, when I publish it, it opens 30 figures windows, which is annoying. How do I keep it from opening the windows, but keeping the figures in the published window?

I've tried with close(figure), but then the figures don't show on the published window.

Thanks in advance

Marco Castanho
  • 395
  • 1
  • 7
  • 24

6 Answers6

17

The simplest thing to do is close all when you are done with the figures. I'm not sure if that can be part of the script or if you have to run it manually after publishing.

shoelzer
  • 10,648
  • 2
  • 28
  • 49
4

At least the plot command has an option to control figure visibility. So you would write something like

h = plot(... , 'Visible', 'off');

I expect these exist for other graphics objects as well, I know it does for the figure associated with anova.

Edit: The above hides the plot but not the figure itself. To hide the figure immediately after it is created, do

set(gcf, 'Visible', 'off')
Matt Phillips
  • 9,465
  • 8
  • 44
  • 75
2

close function in matlab does what you want. Read the documentation for more details

To close all the plots at the same time, you could use

close all

To close a particular figure named 'fig5' (for example), you could use

fig5 = scatter(x, y);
close(fig5)

If you use just "close", only the recent figure will close.

akashrajkn
  • 2,295
  • 2
  • 21
  • 47
0

Perhaps you want hold on which will plot all of the graphs to the same window?

beaker
  • 16,331
  • 3
  • 32
  • 49
0

You can Use subplot(m,n,p) to plot multiple graphs on same figure window.

Ritesh
  • 1
0

to outline the solution,

first step is to plot using handler. Use figa=figure; where figa is now handler for figure. If you use multiple, like 30 you said, figures, then figa=figure;figb=figure.......figad=figure; second step; use the figures for whatever you want to plot in; it has to be done by revoking the figure, for example figure(figa);hold on;plot(x1,y1) figure(figb);hold on;plot(x2,y2)....so on for 30 plots third set is to save all figures saveas(figa,'1.fig');saveas(figb,'2.fig');.......so on for 30 plots; fourth step is to close plots from your monitor close all; fifth step is to reopen those figures openfig('1.fig');openfig('2.fig');.............so on for 30 figs

One suggestion: Use excel to create this long list of figure names and better use separate .m files to avoid bulking your matlab main code.