Extracting data from figure

6 ビュー (過去 30 日間)
University
University 2023 年 10 月 18 日
コメント済み: University 2023 年 10 月 19 日
Hi,
Please how can I extract data from 2D contour at x=0 and y=0 and and use the data to plot a line plot of plot(extracted data from contour at x=0 and y=0, t ) given that t =0:0.1:2.

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 10 月 18 日
移動済み: Walter Roberson 2023 年 10 月 19 日
format long g
fig = openfig('theta.fig');
C = fig.CurrentAxes.Children;
XD1 = C(1).XData; %quiver
XD2 = C(2).XData; %quiver
XD4 = C(4).XData; %contour
YD1 = C(1).YData;
YD2 = C(2).YData;
YD4 = C(4).YData;
UD1 = C(1).UData;
UD2 = C(2).UData;
VD1 = C(1).VData;
VD2 = C(1).VData;
ZD4 = C(4).ZData;
targetx = 0; targety = 0;
[~, idxx1] = min(abs(XD1(1,:) - targetx));
[~, idxy1] = min(abs(YD1(:,1) - targety));
[~, idxx2] = min(abs(XD2(1,:) - targetx));
[~, idxy2] = min(abs(YD2(:,1) - targety));
quiver1_U = UD1(idxy1, idxx1)
quiver1_U =
0.688273554331556
quiver1_V = VD1(idxy1, idxx1)
quiver1_V =
0.725451248815388
quiver2_U = UD2(idxy2, idxx2)
quiver2_U =
2.62314183437878e-07
quiver1_V = VD2(idxy2, idxx2)
quiver1_V =
0.799092966165194
contour_Z = interp2(XD4, YD4, ZD4, targetx, targety);
The above is the value at x = 0 and y = 0.
There is no time information recorded in the figure.
The X and Y grids for the contour data are regular ndgrid() style, but the X and Y grids for the two quiver plots are not regular and even have NaN in them, so interp2() cannot be done, and the above code does not do an interpolation and instead looks up as near as to (0,0) as it can find. Which is a little bit of a problem because there are no exact 0 in x or y for the quivers, and the closest negative x is the same distance as the closest positive x. For a more exact result, a scattered interpolant should be used.
... but the fact that the time data just is not present is a fundamental limitation.
  1 件のコメント
University
University 2023 年 10 月 19 日
Thank you for your response. I will try and get something out this.

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

カテゴリ

Help Center および File ExchangeStress and Strain についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by