Loading a fig file without opening

72 ビュー (過去 30 日間)
JPS
JPS 2021 年 2 月 8 日
コメント済み: Gabriele Bellomia 2022 年 5 月 13 日
Hi,
I have .fig in the current directory and wish to extract data from it. I used the following code for this purpose,
open('power.fig');
a = get(gca,'Children');
xdata = get(a, 'XData');
ydata = get(a, 'YData');
The code works. My problem is it also opens the fig file in a separate figure window. I don't want that to happen. I just want to extract the data.
Ofcourse I could use,
close figure
But it just takes out the graph and shows an empty figure window.
I would be very much grateful if somebody could help me in this.
Thanks in advance!

採用された回答

Fangjun Jiang
Fangjun Jiang 2021 年 2 月 8 日
編集済み: Fangjun Jiang 2021 年 2 月 8 日
f=openfig('power.fig','invisible')
a=get(f,'Children')
...
close(f)
clear f
  3 件のコメント
Noemie Danne
Noemie Danne 2022 年 2 月 28 日
The figure still pop up quickly before closing.
How can I prevent this?
Gabriele Bellomia
Gabriele Bellomia 2022 年 5 月 13 日
Try this:
>> load test.fig -mat hgS_070000
>> hgS_070000
hgS_070000 =
struct with fields:
type: 'figure'
handle: 1
properties: [1×1 struct]
children: [1×1 struct]
special: []
It should work, I just tested it on R2020b Update 7 and it does.
But beware that is undocumented (and probably unintended) behavior. So it might change suddenly.
More info here: https://undocumentedmatlab.com/articles/fig-files-format

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by