フィルターのクリア

Retrieving data from many plots

2 ビュー (過去 30 日間)
manta24
manta24 2018 年 6 月 13 日
コメント済み: manta24 2018 年 6 月 13 日
I'm trying to figure out how to pull data from a figure that has 6 lines plotted on the same graph, and I have no idea how to approach this. I need to pull individual line plot data. Can anyone help me?
My code looks like this:
openfig('filename');
hf = gcf;
gca;
get(gca);
axesObjs = get(h, 'Children');
dataObjs = get(axesObjs, 'Children');
objTypes = get(dataObjs, 'Type');
xdata = get(dataObjs, 'XData');
ydata = get(dataObjs, 'YData');

採用された回答

KSSV
KSSV 2018 年 6 月 13 日
Already you have the data in hand. YOur xdata and ydata will be a cell with your required data. Check the below demo code:
figure
hold on
for i = 1:5
plot(rand(1,10));
end
h = gcf;
axesObjs = get(h, 'Children');
dataObjs = get(axesObjs, 'Children');
objTypes = get(dataObjs, 'Type');
xdata = get(dataObjs, 'XData');
ydata = get(dataObjs, 'YData');
% extract data
for i = 1:numel(xdata)
fprintf('%d line data\n',i) ;
xdata{i}
ydata{i}
end
  1 件のコメント
manta24
manta24 2018 年 6 月 13 日
This works, thanks!

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

その他の回答 (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