Error in quiver plot
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/973870/image.jpeg)
3 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Vector Fields finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!