Feather and quiver not displaying data properly.

Hi,
I have been having trouble using feather (and quiver) plots to display wind direction.
Basically I have hourly summaries of wind direction (0-360) and I am plotting them for each hour. I have them plotted but the arrows are not-corresponding to the proper position. i.e. an arrow pointing to north (0) is not pointing completely vertical as it should, and all angles appear to be off. I've tried many ways of manipulating to solve this issue but nothing has worked. I noticed compass plots have 0 along the x axis which might be related. But with compass you are able to use 'view' to change orientation...that does not appear to work for feather plots.
Here is my code at the moment:
winddirvector=numericvalues(:,7);
ffeather=figure;
p1=subplot(2,1,1);
theta=winddirvector*pi/180;
r=2*ones(size(winddirvector));
[u,v]=pol2cart(theta,r);
wdvp=feather(u,v);
I've tried changing wdvp to feather(sin(u), cos(u)) and it made the arrows point closer but still not accurate direction. I feel there are some math/geometry issues I am missing.
Any help is appreciated as a new MATLAB user.

5 Comments

Please add a few lines to your script to create some sample data for "numericvalues" to illustrate your problem so we can replicate it.
numericvalues(:,7); contains values ranging from 0-360, it is a 22x1 double.
Example:
346
345
345
340
...and so on for 22 rows.
I've attached a photo of the output (which uses the values listed in the example).
I'm fairly certain the issue has to do with the orientation of 0, or North for plots in matlab, someway to rotate it would be ideal. I say this because the arrows appear to be pointing in the correct direction if North or zero is on the positive x axis. Also, for whatever reason the polar axis increases in a counter-clockwise direction unlike a normal compass...not sure what the reasoning behind this is.. doesn't really make sense.
It would have been helpful if you had given us code. I guess you want us to develop it ourselves, so that we can try to help you. So, would this code work (in case anyone is still interested in trying):
winddirvector = randi(360,20,1)
(See how not giving us code wastes time - I may not have time to help you now until tomorrow, whereas with code I might have done something now. But there are others here who might have time tonight.)
Sorry, I'm new to MATLAB but I've provided all the code I am working with.
The values for winddirvector are taken from a .txt file and then listed in a column, here is the code for that:
table_format='%s %s %f %f %f %f %f %f %f %f %f %f %f %f'; %Set table format for each column
file_id=fopen('DataFile.txt'); %open txt file for textscan rawdata=textscan(file_id, table_format,'MultipleDelimsAsOne',1,'Delimiter','\t','HeaderLines',1,'CollectOutput',1); %scan for text, remove header, set delimiter as tab, collect output fclose(file_id); convertdata=cellstr(rawdata{1,1});
numericvalues=(rawdata{1,2});
winddirvector=numericvalues(:,7);
No code other than that is being used to generate the values in winddirvector, so I'm not sure what else to say. The data is simply a column with 22 rows that have values ranging from 0-360. Thanks for taking the time to reply.
To add...
Any values ranging from 0-360 would work, such as making a matrix with some arbitrary numbers, I just don't have code which generates these numbers.
Back to the issue, I want 0 to be pointing north and increasing in a clockwise manner to 360 (Back to 0), like a regular compass. The current way matlab treats it is that 0 is in the east direction and the values increase in a counter-clockwise fashion. This leads to north not being in the orientation I want it to be and the values increasing in the opposite direction. I have not found a way to solve this issue.
My only other thought is transforming the values (ie. making all 0 values into 90 so they point north, and change all the values so they display properly) but there must be a better way to transform the graph.

Sign in to comment.

Answers (0)

Categories

Asked:

on 7 Apr 2013

Community Treasure Hunt

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

Start Hunting!