Error in quiver plot

조회 수: 4 (최근 30일)
Mehak S
Mehak S 2022년 4월 22일
댓글: Voss 2022년 4월 22일
I am trying to plot velocity vectors of the geostrophic wind I have calculated using geopotential height. The final result is a blank plot for the quiver with lat and lon marked. I am unable to find the error. Kindly help me with the same.
ncdisp("_grib2netcdf-webmars-public-svc-blue-006-6fe5cac1a363ec1525f54343b6cc9fd8-NXI9Ix.nc")
time=ncread("_grib2netcdf-webmars-public-svc-blue-006-6fe5cac1a363ec1525f54343b6cc9fd8-NXI9Ix.nc",'time');
lon=ncread("_grib2netcdf-webmars-public-svc-blue-006-6fe5cac1a363ec1525f54343b6cc9fd8-NXI9Ix.nc",'longitude');
lat=ncread("_grib2netcdf-webmars-public-svc-blue-006-6fe5cac1a363ec1525f54343b6cc9fd8-NXI9Ix.nc",'latitude');
z=ncread("_grib2netcdf-webmars-public-svc-blue-006-6fe5cac1a363ec1525f54343b6cc9fd8-NXI9Ix.nc",'z');
u=ncread("_grib2netcdf-webmars-public-svc-blue-006-6fe5cac1a363ec1525f54343b6cc9fd8-NXI9Ix.nc",'u');
v=ncread("_grib2netcdf-webmars-public-svc-blue-006-6fe5cac1a363ec1525f54343b6cc9fd8-NXI9Ix.nc",'v');
contourf(lon,lat,v(:,:,3)')
contourf(lon,lat(1:50),u(:,1:50,3)')
colorbar
colorbar
phi=lat*pi/180;
size(phi)
x=lon*pi/180;
omega=2*pi/(24*3600);
f=2*omega*sin(phi);
y_diff=abs(lat(1)-lat(2))*111000;
x_diff=111000*abs(lon(1)-lon(2)).*cos(phi);
F=repmat(f,1,480);% changing f to a 2d matrix to ease the multiplication
size(z(:,:,2))
% using central difference scheme to evaluate derivatives
z_y=zeros(480,241);
for i=2:240
z_y(:,i)=-(z(:,i+1,3)-z(:,i-1,3));
end
z_y=z_y/(2*y_diff);
z_x=zeros(480,241);
for i=2:479
z_x(i,:)=z(i+1,:,3)-z(i-1,:,3);
end
z_x=z_x./(2*x_diff)';
ug=-z_y./F';
vg=z_x./F';
contourf(lon,lat(1:50),ug(:,1:50)')
colorbar
contourf(lon,lat,vg')
colorbar
contourf(lon,lat,z(:,:,3)')
colorbar
%hold on
[lat, lon]=meshgrid(lat, lon);
quiver(lon,lat,ug,vg);
  댓글 수: 3
Mehak S
Mehak S 2022년 4월 22일
Output is still not showing anything. No change.
Voss
Voss 2022년 4월 22일
@Mehak S Can you upload those files (using the paperclip button), so that we may reproduce the problem?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by