How to export data from a chart to Matlab?

I have a graph in matlab and I want to export data from a graph. Can I export data from a drawing?

I tried very hard to export. In fact, I exported data in the past, but I forgot.

Any help is greatly appreciated.

Thank.

0
source share
1 answer

You can export the vectors xand ythe figure (provided that it is 2D-graphics for a single set of data):

h = plot(1:10);
xVec = get(h,'XData');
yVec = get(h,'YData');

If you do not have a handle, but the shape is open, you can use gcfit gcaas the handle of the current active shape or axis.

If you have several data sets (rows) in the figure, you can get all the associated data:

lines = findobj(h, 'Type', 'line'); //h is the handle to the figure
nlines = length(lines);
points = cell(nlines,2);
for i = 1:nlines
    points{i,1} = get(lines(i),'XData');
    points{i,2} = get(lines(i),'YData');
end
+2
source

All Articles