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!