Plotting Wind magnitude and direction
이전 댓글 표시
Hello, I need to plot hourly wind maps with magnitude as its background and direction arrows above it. I have 2 nc file which contains hourly data of wind magnitude i.e., u component and Wind direction i.e., v component for a month. how can I plot these based on different time interval. hereby i am attaching my both nc file named uwnd and vwnd. Please help me out. Thanks in advance. netcdf file
답변 (2개)
KSSV
2018년 10월 24일
YOu can read the data from ncfile using ncread.
Let u, v be your wind matrices. And X, Y be your locations.
M = sqrt(u.^2+v.^2) ; % magnitude
figure
hold on
pcolor(X,Y,M) ;
shading interp
quiver(X,Y,u,v)
댓글 수: 9
shravani banerjee
2018년 10월 24일
KSSV
2018년 10월 24일
YOu can read all the variables at once..this will be a 3d matrix..from here extract the each time data and plot.
Or
Using ncread you can read variables in a loop of time. Read about ncread
shravani banerjee
2018년 10월 25일
KSSV
2018년 10월 25일
No issues..attach your file...
shravani banerjee
2018년 10월 25일
KSSV
2018년 10월 26일
ncfile1 = 'uwnd.nc';
ncfile2 = 'vwnd.nc';
lon = ncread(ncfile1,'longitude') ; nx = length(lon) ; dx = min(diff(lon)) ;
lat = ncread(ncfile1,'latitude') ; ny = length(lat) ; dy = min(diff(lat)) ;
[X,Y] = meshgrid(lon,lat) ;
t = ncread(ncfile1,'time') ; nt = length(t) ;
pivot = datenum('1900-01-01 00:00:0.0') ;
thedates = datetime(datestr((double(t)/24+pivot))) ;
for i = 1:nt
u = ncread(ncfile1,'u',[1,1,i],[nx,ny,1]) ;
v = ncread(ncfile2,'v',[1,1,i],[nx,ny,1]) ;
s = sqrt(u.^2+v.^2) ;
pcolor(X,Y,s') ;
hold on
quiver(X,Y,u',v',1,'r') ;
title(sprintf('%s',thedates(i)))
hold off
drawnow
end
shravani banerjee
2018년 10월 26일
shravani banerjee
2018년 11월 9일
편집: shravani banerjee
2018년 11월 9일
Bijay Guha
2020년 1월 20일
1 개 추천
This kind of wind vector plots are possible in MATLAB?? Kindly help!
The attached image shows the wind vector plots in the vertical axis. I need the help regarding the arrows only!
Thanks in Advance
Regards
댓글 수: 1
KSSV
2020년 1월 20일
Read about quiver. It should help you.
카테고리
도움말 센터 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!