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
KSSV 2018 年 10 月 24 日

3 投票

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
shravani banerjee 2018 年 10 月 24 日
But how can I extract my u wind and v wind variables based on time and lat/long. I am mainly stuck in this issue. Thanks in advance.
KSSV
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
shravani banerjee 2018 年 10 月 25 日
Can you give me a sample code to extract each time and plotting. It will be a great help as i am new to this software.
KSSV
KSSV 2018 年 10 月 25 日
No issues..attach your file...
shravani banerjee
shravani banerjee 2018 年 10 月 25 日
netcdf file It consist both the u wind and v wind file. Thanks in advance.
KSSV
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
shravani banerjee 2018 年 10 月 26 日
Thank you a lot! I'll try this code and get back to you.
shravani banerjee
shravani banerjee 2018 年 11 月 9 日
編集済み: shravani banerjee 2018 年 11 月 9 日
is this command correct? %
thedates = datetime(datestr((double(t)/24+pivot))) ;
as i am getting an error in this line.
Error using date2time (line 55)
Not enough input arguments
KSSV
KSSV 2018 年 11 月 9 日
編集済み: KSSV 2018 年 11 月 9 日
It is working fine in my version......YOu can comment that line and title line...and check.

サインインしてコメントする。

Bijay Guha
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
KSSV 2020 年 1 月 20 日
Read about quiver. It should help you.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeGraphics Object Properties についてさらに検索

質問済み:

2018 年 10 月 24 日

コメント済み:

2020 年 1 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by