How do I pull data from a figure with multiple plots?
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kenneth Bohn
el 13 de Feb. de 2015
Editada: per isakson
el 6 de Abr. de 2018
I have a Matlab figure with 3 plots on it and I am trying to pull 'YData' from just one of the plots. I am trying to use the following:
h=findobj(gca,'Type');
y=get(h,'YData');
I do realize that this is only picking the YData from one plot but I do not know the plot naming structure or how to select between plots in one figure to pull data. How can I do this?
0 comentarios
Respuesta aceptada
per isakson
el 13 de Feb. de 2015
Editada: per isakson
el 13 de Feb. de 2015
Looks strange too me. Do you use R2014b with the new graphic? If on the old graphic try
axh = findobj( gcf, 'Type', 'Axes' );
axh should be a three element vector
y1 = get( axh(1), 'YData' );
Try
get( axh(1) )
get( axh(2) )
get( axh(3) )
to find an appropriate property, the value of which can be used to distinguish between the axes. It might be different on R2014b.
2 comentarios
per isakson
el 17 de Feb. de 2015
Editada: per isakson
el 17 de Feb. de 2015
y1 = get( axh(1), 'YData' );   is wrong! Now I cannot see why I included it in the first place. (Maybe, I edited your line without thinking.) My idea was to first spot the axes (diagram) of interest out of the three. Next find the children of that axes.
Más respuestas (1)
jtnewgard
el 6 de Abr. de 2018
Editada: per isakson
el 6 de Abr. de 2018
I had some trouble grabbing data from subplots using 'get'. Perhaps I was using the wrong indexing in choosing the subplot.
However, something like this:
g=load('soil_strength.fig','-mat');
depth=g.hgS_070000.children(1,1).children(1,1).properties.YData;
Dr=g.hgS_070000.children(1,1).children(1,1).properties.XData;
phi=g.hgS_070000.children(2,1).children(1,1).properties.XData;
depth_check=g.hgS_070000.children(2,1).children(1,1).properties.YData;
Lets you go through ALL the figure data.
Might take some perusing but you'll find what you need in there.
0 comentarios
Ver también
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!