Clear Filters
Clear Filters

Extracting data points from subplots

21 views (last 30 days)
Hi everybody.
I've run into a pretty big problem with saving data. I was running some tests with a few sensors and accidentally typed in %d\n instead of %d \n. Now I've lost part of my data and the data I did collect is all in one line (i.e. not separated by the \n).
I do however still have the figure pulled up. It has 3 subplots on it with 3 different data sets. These data sets are not predefined, however. I didn't simply plot them all at once, but rather as they came in from my sensors. I was wondering if there was a way to extract each data point from each subplot individually and store it in a neatly organized fashion.
Thanks!

Accepted Answer

Star Strider
Star Strider on 1 Jul 2016
Yes, there is.
FIRST: save your plot as a .fig file. The easiest way to do this is from the plot figure window itself. Click on the floppy disk icon, then choose to save it as a .fig file, and give it some sort of descriptive name. That saves all the data that created it, so you will still have all your data. You can the extract and write it to a .mat file.
Second, to refer to each subplot as the appropriate subplot.
For example:
sp1data = findobj(subplot(3,1,1), 'Type', 'line')
That should get you started.
Save the figure as a .fig file first, then experiment with getting the data from it.
  3 Comments
Star Strider
Star Strider on 1 Jul 2016
My pleasure!
The original in that post refers to getting data from figures in R2014a and previous versions.
Walter Roberson’s Comment refers to getting data from figures in R2014b and later versions. (This is similar to my solution.)
The differences are significant, and what works for R2014a and previous versions (using HG1) will not work in R2014b and later versions (using HG2).
You must have collected a significant amount of data. Your sampling frequency has to be twice the highest frequency component of interest in the signal you’re sampling. More is ‘oversampling’, and while useful isn’t necessary.
Zakia wani
Zakia wani on 23 Nov 2016
i have the same problem.. my c1.fig file has 11 subplots.. i want to extract data from each subplot as each of them represents a different dataset. i was using f= open (‘c1.fig’); h = findobj (f,’type’,’line’); y1 = get (h(1),’Ydata’); y2 = get (h(2),’Ydata’); y3 = get (h(3),’Ydata’); y4 = get (h(4),’Ydata’); y5 = get (h(5),’Ydata’); y6 = get (h(6),’Ydata’); y7 = get (h(7),’Ydata’); y8 = get (h(8),’Ydata’); y9 = get (h(9),’Ydata’); y10 = get (h(10),’Ydata’); y11 = get (h(11),’Ydata’); then i was plotting.. but matlab is just extracting data from the last subplot and putting it in all subplots… what should i do.. any idea would be grateful
Thanks

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!