MATLAB Answers

0

extracting data series from .fig

Asked by Ikechukwu Iroanyanwu on 15 Jul 2019
Latest activity Commented on by Adam
on 16 Jul 2019
Hello, I have been trying to export data from a .fig file to plt in excel but i havent been able to make any progress.
I know there is a code involved but i dont have the right codes. I have attached the .fig file which i am trying to extract data from.

  3 Comments

Adam
on 15 Jul 2019
It would be a lot easier if you saved the data itself rather than figures. You can interrogate the data in a figure though by looking at 'Children' of various components. The figure handle itself should have 4 axes as children. Then drill down further and each axes will have various children of its own - either line plots or scatter plots or whatever they happen to be. Then you can get XData and YData (and ZData, CData if required) from these.
It's easy but boring to do and not so trivial in an automated way for a general plot so you'll have to just code up each bit based on looking at the plots and their components to know which child is which.
I think i did not explain my question properly, I want to extract the data used in plotting the graphs in the .fig file earlier attached. The code i wrote to extract this data does not seem to bve the right codes.
I got this codes from from answers given to people who had asked earlier questions
This is the code
h=openfig('Test1.fig');
h=findobj(gca,'Type', 'line');
x=get(h, 'Xdata');
y=get(h, 'Ydata');
I want to extract the data used in plotting the training Validation and Testing graphs in the picture attachedquestion.PNG
Adam
on 16 Jul 2019
That is what I understood you to mean. Using findobj to find 'Line' objects will return all line objects in the figure though, of which there are 8 (or 12?). I don't know what the code you showed gives you, you didn't say what is wrong with it. What I said above is still the same solution I would give though.

Sign in to comment.

0 Answers