Extracting data from figure
7 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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_V = VD1(idxy1, idxx1)
quiver2_U = UD2(idxy2, idxx2)
quiver1_V = VD2(idxy2, idxx2)
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Stress and Strain 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!