error when using command "quiver"

1 次查看(过去 30 天)
trying to plot zonal and meridional wind data via the "quiver" command and I get the following error:
Error when using quiver (line 58) The size of X must match the size of U or the number of columns of U.
The data I used is attached (.mat) on google drive, it has 90mb, so I didn't put it here. follow the link: https://drive.google.com/open?id=18GgPs-iN3brZHQ3pZNK8GyLt4SOmemY8&authuser=costapereira620%40gmail.com&usp=drive_fs
Anyone a solution??
% load 'dat_era5_201007.mat'
%%
t1 = datetime(2007,07,1,0,0,0); % 01/jul/2007 as 00h
t2 = datetime(2007,07,31,23,0,0); % 31/jul/2007 as 23h
t = t1:hours(1):t2; % sera gerado datas no intervalo de t1 a t2
%%
cd 'H:\DADOS_SCi-MSc\DadosEra5PreComp'
data1 = load('dat_era5_201007.mat', 'u10');
data3 = load('dat_era5_201007.mat', 'v10');
u10=data1.u10;
v10=data3.v10;
u10=u10(:,:,t==t);
v10=v10(:,:,t==t);
u10mean=mean(u10,3);
v10mean=mean(v10,3);
load('dat_era5_201007.mat', 'lon');
load('dat_era5_201007.mat', 'lat');
%%
figure
[x, y]=meshgrid(lon(:,1),lat(:,1));
quiver(x,y,u10mean,v10mean)

采纳的回答

Augusto Gabriel da Costa Pereira
if you perform the following tweak it will work fine
figure
imagesc(lon(:,1),lat(:,1),v10mean)
[x, y]=meshgrid(lon(:,1),lat(:,1))
hold on
h=quiver(x,y,u10mean',v10mean','w')

更多回答(1 个)

Cris LaPierre
Cris LaPierre 2023-3-30
编辑:Cris LaPierre 2023-3-30
You have created x and y so that they are 53x57 arrays, but u10mean and v10mean are 57x53. As the error message says, they must be the match.
Try this instead.
[x, y]=meshgrid(lat(:,1),lon(:,1));
quiver(x,y,u10mean,v10mean)

类别

Help CenterFile Exchange 中查找有关 Vector Fields 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by