Extracting data from figure

2 次查看(过去 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 CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by