Extracting data from figure
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Walter Roberson
il 18 Ott 2023
Spostato: Walter Roberson
il 19 Ott 2023
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.
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!