Reputation: 141340
I followed the instructions here. I have data in the fig -file:
I run
s = load('filename.fig','-mat');
I get many fields of data:
I would like to get data only in the range from -1.5 to 2 in a list.
How can you retrieve data from such a Matlab data-structure?
Upvotes: 1
Views: 555
Reputation: 30589
I hinted at this process in my previous answer to a different question. As you know, .fig files are actually MAT-files that contain data which specifies the figure. To load the .fig data into a MATLAB struct
and then access the XData
and YData
properties of a specific axes and series (you can have multiple axes and series):
>> s = load('filename.fig','-mat');
s =
hgS_070000: [1x1 struct]
>> axesNum = 1; seriesNum = 1;
>> series = s.hgS_070000.children(axesNum).children(seriesNum)
series =
type: 'graph2d.lineseries'
handle: 172.0051
properties: [1x1 struct]
children: []
special: []
>> XData = series.properties.XData;
>> YData = series.properties.YData;
Now you just have to grab the samples you want:
rangeMask = YData >= -1.5 & YData <= 2;
YDataSub = YData(rangeMask);
XDataSub = XData(rangeMask);
See also this examination of the .fig file format, for a simplified example with only one axis and one series, thus not using any axesNum
and seriesNum
indexes.
Upvotes: 1