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!

 Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 8 Feb. 2021
Bearbeitet: Fangjun Jiang am 8 Feb. 2021

1 Stimme

f=openfig('power.fig','invisible')
a=get(f,'Children')
...
close(f)
clear f

3 Kommentare

JPS
JPS am 11 Feb. 2021
Thank You Mr. Fangjun Jiang !
Noemie Danne
Noemie Danne am 28 Feb. 2022
The figure still pop up quickly before closing.
How can I prevent this?
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Hilfe-Center und File Exchange

Produkte

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by