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 CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by