finding data of a plot

1 view (last 30 days)
maryam
maryam on 6 Oct 2014
Commented: Azzi Abdelmalek on 6 Oct 2014
hi. i have a plot like this and want to find these data value. i use "save work space as" and save data in a .mat file. but when i load mat file nothing appears. could you suggest me what to do?thanks in advance

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 6 Oct 2014
Look at this example
% -----Example----------------------
x=repmat((1:10)',1,3);
y=rand(10,3);
for k=1:3
subplot(3,1,k);
plot(x(:,k),y(:,k));
end
%------The code-----------------------
h=findobj(gcf,'type','axes');
for k=1:3
f=get(h(k),'children');
xi{k}=get(f,'xdata');
yi{k}=get(f,'ydata');
end
outx=fliplr(cell2mat(xi')');
outy=fliplr(cell2mat(yi')');
  3 Comments
Adam
Adam on 6 Oct 2014
You need to create the code yourself using the example under the "The code" part. The "Example" section just creates a figure to replicate the state you start from with a pre-existing figure.
Azzi Abdelmalek
Azzi Abdelmalek on 6 Oct 2014
Myriam, If you have a figure, open it, then use the second part of my code, the first one is just an example
Open your figure then run this code
%------The code-----------------------
h=findobj(gcf,'type','axes');
for k=1:3
f=get(h(k),'children');
xi{k}=get(f,'xdata');
yi{k}=get(f,'ydata');
end
outx=fliplr(cell2mat(xi')');
outy=fliplr(cell2mat(yi')');

Sign in to comment.

Categories

Find more on Graphics Object Identification in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!