How to get data points from graph

15 次查看(过去 30 天)
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 个评论
Dyuman Joshi
Dyuman Joshi 2023-12-1
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?
Syed Mohiuddin
Syed Mohiuddin 2023-12-1
i want to have x and y coordinates values from the graph
Regards,
Syed Mohiuddin

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2023-12-1
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
x = 1×50
-1.0000 -0.9592 -0.9184 -0.8776 -0.8367 -0.7959 -0.7551 -0.7143 -0.6735 -0.6327 -0.5918 -0.5510 -0.5102 -0.4694 -0.4286 -0.3878 -0.3469 -0.3061 -0.2653 -0.2245 -0.1837 -0.1429 -0.1020 -0.0612 -0.0204 0.0204 0.0612 0.1020 0.1429 0.1837
y = Lines.YData % Dependent Variable
y = 1×50
0 0.0072 0.0143 0.0211 0.0278 0.0343 0.0407 0.0468 0.0528 0.0587 0.0643 0.0698 0.0752 0.0803 0.0852 0.0900 0.0946 0.0989 0.1030 0.1069 0.1106 0.1140 0.1171 0.1200 0.1225 0.1247 0.1266 0.1281 0.1293 0.1300
figure
plot(x, y, '-r', 'LineWidth',2)
grid
xlabel('x')
ylabel('y')
title('Recovered Data')
axis('equal') % Optional
.
  11 个评论
Syed Mohiuddin
Syed Mohiuddin 2023-12-2
Thank you thank you thank you, great, this was exactly what i wanted.

请先登录,再进行评论。

更多回答(1 个)

Mathieu NOE
Mathieu NOE 2023-12-1
编辑:Voss 2023-12-1
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 个评论
Mathieu NOE
Mathieu NOE 2023-12-4
you probably did not download the function with the link I mentionned above
for your convenience I attach here to this post

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by