Error with quiverm function
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Rob Comer
2012년 2월 5일
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
Chad Greene
2014년 7월 22일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Vector Fields에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!