I have a matlab figure with my real data and a fitted curve on that data. Can I extract the fitted values from that matlab figure?

2 Kommentare

Geoff Hayes
Geoff Hayes am 12 Mai 2020
Arpan - how was the fitted curve added to that plot? Which function or functions were used to create it?
Arpan Bhattacharya
Arpan Bhattacharya am 12 Mai 2020
Hi Geoff,
Its from a matlab based software. I usedan exponential equation to fit my data. The only thing is I can save the fitted curve as matlab figure (.fig format). Is that what you are asking?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ameer Hamza
Ameer Hamza am 12 Mai 2020

0 Stimmen

If it contains a single line, then you can do something like this
fig = openfig('test.fig');
Line = findobj(fig, 'type', 'line');
x = Line.XData; % x-data
y = Line.XData; % y-data
If there are multiple lines, then the variable 'Line' will be an array. In that case, you can index into 'Line' to get data for a specific line. For example
x = Line(2).XData; % x-data
y = Line(2).XData; % y-data
this code access the 2nd line in array 'Line'

4 Kommentare

Arpan Bhattacharya
Arpan Bhattacharya am 14 Mai 2020
Hi Ameer,
Thanks. The command for the first line is working but the second line command is not woriking. It's giving me this error "Index exceeds the number of array elements (1)."
Ameer Hamza
Ameer Hamza am 14 Mai 2020
It means you have a single line in your figure file.
Arpan Bhattacharya
Arpan Bhattacharya am 14 Mai 2020
Thanks. I got this working.
Ameer Hamza
Ameer Hamza am 14 Mai 2020
What was the issue?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 12 Mai 2020

Kommentiert:

am 14 Mai 2020

Community Treasure Hunt

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

Start Hunting!

Translated by