Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to plot a quiver/direction field

Subject: How to plot a quiver/direction field

From: Niels

Date: 17 Aug, 2010 09:10:23

Message: 1 of 4

Hello,

I'm looking for the best way to visualise some data.

The data is that I have are all different variables with the same setup. They are all matrices and every cell in the matrix refers to a point in a certain area. All points are 1 meter separated from each other. So it's easy for most of the variables to visualise them because I can use 'contour' or 'image' to plot them.

But one of the variables is a direction so it's a number in degrees (between 0°-360°) and I can't seem to manage to visualise this one to my likings. I've tought about quiver or streamslice or something like that but I can't get any usefull results... Anybody options how to visualise this best?

Thank you,
Niels

Subject: How to plot a quiver/direction field

From: Sean

Date: 17 Aug, 2010 15:36:08

Message: 2 of 4

"Niels " <niels.balens@mow.vlaanderen.be> wrote in message <i4djlv$13e$1@fred.mathworks.com>...
> Hello,
>
> I'm looking for the best way to visualise some data.
>
> The data is that I have are all different variables with the same setup. They are all matrices and every cell in the matrix refers to a point in a certain area. All points are 1 meter separated from each other. So it's easy for most of the variables to visualise them because I can use 'contour' or 'image' to plot them.
>
> But one of the variables is a direction so it's a number in degrees (between 0°-360°) and I can't seem to manage to visualise this one to my likings. I've tought about quiver or streamslice or something like that but I can't get any usefull results... Anybody options how to visualise this best?
>
> Thank you,
> Niels

Can you provide a (small) sample of your data? It should be doable with quiver() or maybe coneplot(). You'll just have to convert your angle to a [u v] displacement.

Subject: How to plot a quiver/direction field

From: Niels

Date: 18 Aug, 2010 06:21:08

Message: 3 of 4

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i4ea98$hvn$1@fred.mathworks.com>...
> "Niels " <niels.balens@mow.vlaanderen.be> wrote in message <i4djlv$13e$1@fred.mathworks.com>...
> > Hello,
> >
> > I'm looking for the best way to visualise some data.
> >
> > The data is that I have are all different variables with the same setup. They are all matrices and every cell in the matrix refers to a point in a certain area. All points are 1 meter separated from each other. So it's easy for most of the variables to visualise them because I can use 'contour' or 'image' to plot them.
> >
> > But one of the variables is a direction so it's a number in degrees (between 0°-360°) and I can't seem to manage to visualise this one to my likings. I've tought about quiver or streamslice or something like that but I can't get any usefull results... Anybody options how to visualise this best?
> >
> > Thank you,
> > Niels
>
> Can you provide a (small) sample of your data? It should be doable with quiver() or maybe coneplot(). You'll just have to convert your angle to a [u v] displacement.


Good morning,

You can find a .mat -file here: http://rapidshare.com/files/413615604/scPr_H5_NNW_dir.mat

Thank you for your interest,
Niels

Subject: How to plot a quiver/direction field

From: Sean

Date: 18 Aug, 2010 13:58:37

Message: 4 of 4

"Niels " <niels.balens@mow.vlaanderen.be> wrote in message <i4fu4k$aqo$1@fred.mathworks.com>...
> "Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i4ea98$hvn$1@fred.mathworks.com>...
> > "Niels " <niels.balens@mow.vlaanderen.be> wrote in message <i4djlv$13e$1@fred.mathworks.com>...
> > > Hello,
> > >
> > > I'm looking for the best way to visualise some data.
> > >
> > > The data is that I have are all different variables with the same setup. They are all matrices and every cell in the matrix refers to a point in a certain area. All points are 1 meter separated from each other. So it's easy for most of the variables to visualise them because I can use 'contour' or 'image' to plot them.
> > >
> > > But one of the variables is a direction so it's a number in degrees (between 0°-360°) and I can't seem to manage to visualise this one to my likings. I've tought about quiver or streamslice or something like that but I can't get any usefull results... Anybody options how to visualise this best?
> > >
> > > Thank you,
> > > Niels
> >
> > Can you provide a (small) sample of your data? It should be doable with quiver() or maybe coneplot(). You'll just have to convert your angle to a [u v] displacement.
>
>
> Good morning,
>
> You can find a .mat -file here: http://rapidshare.com/files/413615604/scPr_H5_NNW_dir.mat
>
> Thank you for your interest,
> Niels

I think this is what you want:

%%%%
%renamed your 'Dir' variable 'data' because dir is a builtin function.

%Indices of every point
[xx yy] = meshgrid(1:size(data,2),1:size(data,1));

%Table form for further computations
data = [xx(:), yy(:), data(:)];

%Get rid of all NaNs.
data(any(isnan(data),2),:) = [];

%Keep in table form, add u,v components of vector in the 4th,5th columns of
%data. u = cosd(theta),v = sind(theta); all vectors end on unit circle.
%Calculated with cartesian positive x-axis being theta = 0.
data = cat(2,data,cosd(data(:,3)),sind(data(:,3)));

%Plot it
quiver(data(:,1),data(:,2),data(:,4),data(:,5))

%SCd

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us