extract data from matlab figures

2 ビュー (過去 30 日間)
Qian Xun
Qian Xun 2017 年 8 月 20 日
コメント済み: Jan 2017 年 8 月 20 日
Hi, I have a matlab figure without original data, I dried to extract data from the figure using the following code, I just got 101 groups of data. But if I want to extract more data, what should I do? I also use the brush/select data button, I got the same numbers of data.
% get the handle of the current figure
fig = gcf;
% get the handles of the active axes
axes = get(fig, 'Children');
% get the handles of the data objects associated with each axis
data = get(axes, 'Children');
% these cell variables will hold the extracted data
x_data = {};
y_data = {};
% go through all line objects and extract X and Y data
for i=1:length(data)
object_type = get(data{i}, 'Type');
current_data = data{i};
if iscell(object_type)
for j=1:length(object_type)
% check whether the current object matches the desired data type
if strcmp(object_type{j}, 'line')
% save extracted data
x_data = vertcat(x_data, get(current_data(j), 'XData'));
y_data = vertcat(y_data, get(current_data(j), 'YData'));
end
end
else
% check whether the current object matches the desired data type
if strcmp(object_type, 'line')
save extracted data
x_data = vertcat(x_data, get(current_data, 'XData'));
y_data = vertcat(y_data, get(current_data, 'YData'));
end
end
end
  1 件のコメント
Jan
Jan 2017 年 8 月 20 日
How could we know this without having the figure? Perhaps there are multiple tabs, or invisible or hidden axes objects? Perhaps the data are not stores as 'line' objects?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Object Programming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by