Way to save figures to .fig file as visible from matlab live script?

11 次查看(过去 30 天)
I have a matlab live script that generates some figures, then uses saveas() to save them to .fig files. The problem is that these figures have "visible" set false by default, so if you double left click to try and open them nothing happens. You have to use openfig() and set visible within openfig.
I tried setting the fig visible before saving via set(gcf, 'Visible', 'on') and this does properly set the property before saving, but this opens a new figure window I have to then close.
Is there a way to programatically export these figures as .fig files with visible set true by default? Without opening a new window.

回答(1 个)

Cedric Kotitschke
Cedric Kotitschke 2023-11-16
Why don't you set the visible property to 'off' after saving?
set(gcf, 'Visible', 'on')
saveas(gcf, 'figurename.fig')
set(gcf, 'Visible', 'off')
  1 个评论
David Alston
David Alston 2024-1-8
That just hides the figure window, it does not prevent it from opening. I had tried setting them visible before saving, and that does work on the .fig files. The problem is that also opens a new figure window seperate from the live script which I am trying to prevent.
But what I have works for now; I just have to close all at the end of the section. I was just looking to see if there was a better method to programatically save figures from a live script without opening that new window.
Thank you for your answer!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

产品


版本

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by