plot field form a orderd vector
1 view (last 30 days)
Show older comments
Hi,
I need some help to plot the output of a model. I am trying to plot a 3D wind filed and this is what I have (this is just a minimal working example):
lat=[10,11,10,12,13,10]
lon=[50,51,52,54,52,51]
height=[10,50,120]
wind_speed=[7,4,3,2,1,6 ; 8,6,5,4,5,9; 10,8,8,7,6,11]
wind_direction=[120,110,150,115,117,113; 122,113,154,118,119,115; 126,117,159,121,120,117]
What I would like to have is a 3D map with arrows indicatin the direction and intensity of the wind at height and lat lon position established by the vectors lat lon height. A maybe simpler intermidiate step could be plot just a 2d plot correspoding to a specific height.
The problem is with the localization with lat lon. The position in the vector (or in the comlun for wind speed and direction) idetify correspoding values. This is to say that the column of wind speed values
wind_speed(:,2)
must be plotted in positions that are stored in lat(2) e lon(2)
This is clear to me . I just don't know how to "expalin" it to matlab XD.
I hope I maaged to expaine my problem! Any help is appriciated!
Giacomo
0 Comments
Answers (1)
Walter Roberson
on 12 Jan 2021
lat=[10,11,10,12,13,10]
lon=[50,51,52,54,52,51]
height=[10,50,120]
wind_speed=[7,4,3,2,1,6 ; 8,6,5,4,5,9; 10,8,8,7,6,11]
wind_direction=[120,110,150,115,117,113; 122,113,154,118,119,115; 126,117,159,121,120,117]
latin = repmat(lat, length(height), 1);
lonin = repmat(lon, length(height), 1);
hin = repmat(height(:), 1, length(lat));
%probe positions
platvec = min(lat):max(lat);
plonvec = min(lon):max(lon);
pheightvec = height;
[latG, lonG, hG] = meshgrid(platvec, plonvec, pheightvec);
S = scatteredInterpolant(latin(:), lonin(:), hin(:), wind_speed(:));
SG = S(latG, lonG, hG);
D = scatteredInterpolant(latin(:), lonin(:), hin(:), wind_direction(:));
DG = D(latG, lonG, hG);
WG = zeros(size(DG));
quiver3(latG, lonG, hG, SG, DG, WG);
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!