error when using command "quiver"

1 view (last 30 days)
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)

Accepted Answer

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')

More Answers (1)

Cris LaPierre
Cris LaPierre on 30 Mar 2023
Edited: Cris LaPierre on 30 Mar 2023
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)

Categories

Find more on Vector Fields in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!