How to get data points from graph

19 ビュー (過去 30 日間)
Syed Mohiuddin
Syed Mohiuddin 2023 年 12 月 1 日
コメント済み: Syed Mohiuddin 2023 年 12 月 7 日
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.
Star Strider
Star Strider 2023 年 12 月 2 日
As always, my pleasure!

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

その他の回答 (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
Syed Mohiuddin
Syed Mohiuddin 2023 年 12 月 7 日
Thank you

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by