quiverm miscalculates some angles?
Show older comments
I am using quiverm to plot directions given by (u,v) coordinates. The mapped directions look fine when u and v are both positive or both negative. The mapped directions are incorrect if either u or v are negative. Any suggestions? (Here is my code; yes, I'm new to MATLAB):
%Clear and close all files, windows, etc.
clc;
close all;
clear;
length=3;
lat=[43.63, 24.55, 47.93, 35.22, 37.62, 25.90, 32.73];
lon=[-70.30, -81.75, -124.57, -75.62, -122.40, -97.42, -117.17];
u=[0.4209, 0.1473, 0.2935, 0.5070, 0.3087, -0.1520, -0.3779];
v=[-0.2750, -0.4750, 0.6447, 0.5786, 0.3922, 0.8671, -0.3376];
%Create a vector of State Names for plotting
stuse={'Maine' 'New Hampshire' 'Massachusetts' 'Rhode Island' 'Connecticut'...
'New York' 'Pennsylvania' 'New Jersey' 'Delaware' 'Maryland' 'Virginia'...
'North Carolina' 'South Carolina' 'Georgia' 'Florida' 'Alabama'...
'Mississippi' 'Louisiana' 'Texas' 'California' 'Oregon' 'Washington'};
%Create a map
ax = usamap(stuse);
set(ax, 'Visible', 'off')
latlim = getm(ax, 'MapLatLimit');
lonlim = getm(ax, 'MapLonLimit');
states = shaperead('usastatehi',...
'UseGeoCoords', true, 'BoundingBox', [lonlim', latlim']);
geoshow(ax, states,'FaceColor','white')
grid off;
%scale u,v components so they all have the same magnitude (1.0)
for i=1:7
scale(1,i)=(u(1,i)*u(1,i))+(v(1,i)*v(1,i));
lu(1,i)=u(1,i)/sqrt(scale(1,i));
lv(1,i)=v(1,i)/sqrt(scale(1,i));
end;
%change arrow length according to variable 'length'
lu=lu*length;
lv=lv*length;
%plot arrows
quiverm(lat,lon,lu,lv,0);
scatterm(lat,lon,10,'o','k','filled');
The arrow for Portland ME (lat 43.63) should be pointing to 327 degrees; the arrow for Key West FL (lat 24.55) should be pointing to 287 deg; and the arrow for Brownsville TX (lat 25.90) should be pointing to 100 deg.
The arrows for Quillayute WA (lat 47.93), Cape Hatteras NC (lat 35.22), San Francisco CA (lat 37.62), and San Diego CA (lat 32.73) are plotted correctly.
Accepted Answer
More Answers (0)
Categories
Find more on Weather and Atmospheric Science 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!