COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### How to plot a quiver/direction field

• Email
• Follow

```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
```
 0

See related articles to this posting

```"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.
```
 0

```"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

Niels
```
 0

```"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
```
 0