How to get data points from graph
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Syed Mohiuddin
el 1 de Dic. de 2023
Comentada: Syed Mohiuddin
el 7 de Dic. de 2023
hi,
I have graph, i need to prepare a table of the data for x and y terms. How should i get the data points from the enclosed graph, please let me know.
Regards,
Syed Mohiuddin
2 comentarios
Dyuman Joshi
el 1 de Dic. de 2023
It's not clear to me what you want to do.
What does 'terms' mean here?
Do you want to x and y coordinate values of the points used to plot that graph from the figure?
Respuesta aceptada
Star Strider
el 1 de Dic. de 2023
Getting information from .fig files has changed over the years. This approach works with the most recent releases.
Use the findobj function with the axes handle to return specifc ‘Line’ objects (since there may be more than one), then index into them, for example:
Lines = findobj(Ax, 'Type','line')
X{1} = Lines(1).XData;
Y{1} = Lines(1).YData;
If there are more than one, this can be done in a loop.
There is only one here, so just do this —
openfig('data points.fig');
% Ax = hf.CurrentAxes; % One Option
Ax = gca; % Another Option
Lines = findobj(Ax, 'Type','line'); % Return Handles To All 'Line' Objects
x = Lines.XData % Independent Variable
y = Lines.YData % Dependent Variable
figure
plot(x, y, '-r', 'LineWidth',2)
grid
xlabel('x')
ylabel('y')
title('Recovered Data')
axis('equal') % Optional
.
11 comentarios
Más respuestas (1)
Mathieu NOE
el 1 de Dic. de 2023
Editada: Voss
el 1 de Dic. de 2023
hello
the main code is very simple (use the attached function - credits to his creator !)
data = extract_data_from_figures('data points.fig');
VN = data.names; % variable names
data = data.Y;
x = data(:,1);
y = data(:,2);
figure(1)
plot(x,y);
3 comentarios
Mathieu NOE
el 4 de Dic. de 2023
you probably did not download the function with the link I mentionned above
for your convenience I attach here to this post
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!