如何从Matlab中的图形导出数据? [英] How to export data from the graph in Matlab?
问题描述
我在matlab中有一个图形,我想从图形中导出数据.是否可以从图中导出数据?
I have a graph in matlab and I want to export the data from the graph. Is it possible to export data from the figure ?
我努力出口.实际上,我过去曾导出过数据,但我忘记了.
I tried hard to export. Actually, I had exported data in the past but I forgot.
我们非常感谢您的帮助.
Any help is highly appreciated.
谢谢.
推荐答案
您可以通过以下方式从图形中导出x
和y
向量(假设该图形是单个数据集的2D图):
You can export x
and y
vectors from a figure (assuming the figure is a 2D plot for a single data set) by:
h = plot(1:10);
xVec = get(h,'XData');
yVec = get(h,'YData');
如果没有手柄但图形已打开,则可以使用gcf
,gca
作为当前活动图形或轴的手柄.
If you dont have the handle but the figure is open, then you can use gcf
, gca
as the handle for the current active figure or axis.
如果图中有多个数据集(线),则可以通过以下方式获取所有关联数据:
If you have multiple data sets (lines) in the figure you can get all of the associated data by:
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
这篇关于如何从Matlab中的图形导出数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!