How to save Matlab GUI-Window as vector graphics?

I want to save the whole Window of GUI as a vector graphic like these
I tried to use
fig=openfig('test_gui.fig');
fig.InvertHardcopy = 'off';
set(fig,'PaperPositionMode','auto');
print(fig,'-dpdf','test_gui.pdf')
But only get the GUI-Frame without Figure in PDF
How can I get both of them as a vector graphic ?
Thanks in advance

回答 (1 件)

Sonam Gupta
Sonam Gupta 2018 年 3 月 26 日

0 投票

This is happening because the handle 'fig' in your code is pointing only to GUI frame. Use the following code instead:
if true
fig= test_gui.fig;
fig.InvertHardcopy = 'off';
set(fig,'PaperPositionMode','auto');
print(fig,'-dpdf','test_gui.pdf')
end
I hope this helps.

3 件のコメント

Ting Sun
Ting Sun 2018 年 3 月 26 日
fig= test_gui.fig;
I tried it, but it shows error ...
Ting Sun
Ting Sun 2018 年 3 月 26 日
by using fig=gcf; works! thanks
Ashishkumar Gupta
Ashishkumar Gupta 2023 年 1 月 9 日
編集済み: Ashishkumar Gupta 2023 年 1 月 9 日
my Gui file name is plotgraph.mlapp. It does not have .fig extension.!! What's the workaround here?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

質問済み:

2018 年 3 月 14 日

編集済み:

2023 年 1 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by