How do I extract data from MATLAB figures? (some error)

2 Ansichten (letzte 30 Tage)
jaejin kim
jaejin kim am 7 Okt. 2020
Kommentiert: Ameer Hamza am 7 Okt. 2020
I want to extract 'y data' value from a fig file.
I input the following code in Matlab R2018b:
ezplot('y*(0.6326*log(y)+4.419*y + 30.48) - 80*sin(x)^2',[-5 5 -1 4])
>> h= gcf;
axObjs = h.Children
dataObjs = axObjs.Children
x = dataObjs(1).XData
y = dataObjs(1).YData
but I get the value for 'x axis' and 'y axis'. I don't need y axis. I only want to get the value of y date.
No matter what i do i can't make this to work. It's very strange. Any help will be greatly appreciated. Thanks in advance.

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 7 Okt. 2020
Bearbeitet: Ameer Hamza am 7 Okt. 2020
ezplot() is being depreciated. Also, it generates a contour object, which is not so helpful to extract the data. Use fimplicit instead.
f = fimplicit(@(x, y) y.*(0.6326*log(y)+4.419*y + 30.48) - 80*sin(x).^2, [-5 5 -1 4]);
h= gcf;
axObjs = h.Children;
dataObjs = axObjs.Children;
x = dataObjs(1).XData;
y = dataObjs(1).YData;
  4 Kommentare
jaejin kim
jaejin kim am 7 Okt. 2020
It was really helpful!! Thanks for your help.
Ameer Hamza
Ameer Hamza am 7 Okt. 2020
I am glad to be of help!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Objects finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by