Error with quiverm function
3 views (last 30 days)
Show older comments
I have the following code that returns me contour plots of phi, Q and quiver plots of u,v on a map. The first section just fiddles around with the data so its the write magnitude and shape.
However when I use the quiverm function it returns me this error:
??? Error using ==> quiverm
Inconsistent dimensions for inputs
Error in ==> model at 54
quiverm(lat,lon,u,v)
phi, Q, u and v are all 21*41 arrays. Longitude and latitude (lon and lat) are length 41 and 21 respectively.
Can anyone tell me why I'm getting this error?
close all
clear all
load 'Q.ascii'
load 'u.ascii'
load 'v.ascii'
load 'phi.ascii'
m = 43;
n = 21;
Q = reshape(Q,n,41);
u1 = reshape(u,n,m);
v1 = reshape(v,n,m);
phi1 = reshape(phi,n,m);
Q = flipud(Q);
u2 = flipud(u1);
v2 = flipud(v1);
phi2 = flipud(phi1);
u3 = u2/100;
v3 = v2/100;
phi3 = phi2/100;
u = u3(:,2:42);
v = v3(:,2:42);
phi = phi3(:,2:42);
lat = zeros(1,21);
lon = zeros(1,41);
for n = 1:21
lat(n) = -40.5 + 4.5*(n-1);
end
for m = 1:41
lon(m) = (9*(m-1));
end
figure(4)
axesm('eqdcylin', 'maplonlimit', [0 360], 'maplatlimit' , [-40.5 40.5], 'frame', 'on', 'grid', 'on');
geoshow('landareas.shp', 'facecolor', 'none');
contourfm(lat,lon,phi);
figure(5)
axesm('eqdcylin', 'maplonlimit', [0 360], 'maplatlimit' , [-40.5 40.5], 'frame', 'on', 'grid', 'on');
geoshow('landareas.shp', 'facecolor', 'none');
contourm(lat,lon,Q);
figure(1)
axesm('eqdcylin', 'maplonlimit', [0 360], 'maplatlimit' , [-40.5 40.5], 'frame', 'on', 'grid', 'on');
geoshow('landareas.shp', 'facecolor', 'none');
quiverm(lat,lon,u,v)
0 Comments
Answers (2)
Rob Comer
on 5 Feb 2012
Unlike quiver, quiverm does not automatically expand its first two inputs if they are vectors and the third and fourth inputs are matrices, even if their lengths are consistent with size of the two matrices. You need to precede the call to quiverm with a call to meshgrat.
I see no need for this inconsistency; I think that what you tried should work and that quiverm should be fixed to support it. Thanks for pointing out the issue.
0 Comments
Chad Greene
on 22 Jul 2014
Matlab's quiverm function mixes up u and v. It also scales the vectors in a strange way. Andrew Roberts' ncquiverref fixes the problems, as does quivermc.
0 Comments
See Also
Categories
Find more on Vector Fields in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!