Azzera filtri
Azzera filtri

Extracting data from a .fig file

62 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Dyuman Joshi
Dyuman Joshi il 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')
a =
3×1 graphics array: ConstantLine (L_{car}) Line (Q_{t} - Elastique) Line (Exp)
%x, y and z data for the 2nd graphics object
x2 = a(2).XData
x = 1×255
0 0.2000 0.4000 0.6000 0.8000 1.0000 1.2000 1.4000 1.6000 1.8000 2.0000 2.2000 2.4000 2.6000 2.8000 3.0000 3.2000 3.4000 3.6000 3.8000 4.0000 4.2000 4.4000 4.6000 4.8000 5.0000 5.2000 5.4000 5.6000 5.8000
y2 = a(2).YData
y = 1×255
0 0.0010 0.0012 0.0014 0.0016 0.0017 0.0018 0.0019 0.0020 0.0021 0.0021 0.0022 0.0023 0.0023 0.0024 0.0024 0.0025 0.0025 0.0026 0.0026 0.0027 0.0027 0.0028 0.0028 0.0029 0.0029 0.0029 0.0030 0.0030 0.0030
z2 = a(2).ZData
z = 1×0 empty double row vector
  2 Commenti
Wissem-Eddine KHATLA
Wissem-Eddine KHATLA il 23 Nov 2023
Thank you : I misunderstood the result of the get function. Thanks again
Dyuman Joshi
Dyuman Joshi il 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')
a =
3×1 graphics array: ConstantLine (L_{car}) Line (Q_{t} - Elastique) Line (Exp)
get(a(1))
Alpha: 0.7000 Annotation: [1×1 matlab.graphics.eventdata.Annotation] BeingDeleted: off BusyAction: 'queue' ButtonDownFcn: '' Children: [1×1 ListOfPointsHighlight] Color: [1 0 0] ColorMode: 'manual' ContextMenu: [0×0 GraphicsPlaceholder] CreateFcn: '' DeleteFcn: '' DisplayName: 'L_{car}' FontAngle: 'normal' FontName: 'Helvetica' FontSize: 10 FontWeight: 'normal' HandleVisibility: 'on' HitTest: on InterceptAxis: 'y' Interpreter: 'tex' Interruptible: on Label: {'L_{car}'} LabelHorizontalAlignment: 'right' LabelOrientation: 'aligned' LabelVerticalAlignment: 'top' LineStyle: '-.' LineStyleMode: 'manual' LineWidth: 2 Parent: [1×1 Axes] PickableParts: 'visible' Selected: off SelectionHighlight: on SeriesIndex: 'none' Tag: '' Type: 'constantline' UserData: [] Value: 0.0082 Visible: on
%Though Get the axis and value associated with it
a(1).InterceptAxis
ans = 'y'
a(1).Value
ans = 0.0082

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graphics Object Identification in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by