Extracting data from a .fig file
78 views (last 30 days)
Show older comments
Wissem-Eddine KHATLA
on 23 Nov 2023
Commented: Dyuman Joshi
on 23 Nov 2023
Hello everyone,
I know this has already been discussed in an another discussion but I want to extract data from a particular figures and I keep having an error while using the habitual procedure :
open('Comparaison R(t) EXP x THE.fig');
a = get(gca,'Children');
xdata = get(a, 'XData');
ydata = get(a, 'YData');
zdata = get(a, 'ZData');
I obtain the following error :
Error using matlab.graphics.primitive.Data/get
Unrecognized property XData for class ConstantLine.
Anyone knows how I can have access to these datas ?
Thanks for your help in advance,
Sincerely
0 Comments
Accepted Answer
Dyuman Joshi
on 23 Nov 2023
There are multiple objects in the figure. You need to choose the object(s) for which you want to get the data -
open('Comparaison R(t) EXP x THE.fig')
a = get(gca,'Children')
%x, y and z data for the 2nd graphics object
x2 = a(2).XData
y2 = a(2).YData
z2 = a(2).ZData
2 Comments
Dyuman Joshi
on 23 Nov 2023
You're welcome!
Also, note that not every graphical object will have coordinate data associated with it.
A ConstantLine object is an example of that -
open('Comparaison R(t) EXP x THE.fig')
a = get(gca,'Children')
get(a(1))
%Though Get the axis and value associated with it
a(1).InterceptAxis
a(1).Value
More Answers (0)
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!