From: Lisette de Boer on
Hallo,

I'm simulating fish schooling in matlab, using quiver3. I would like to make the color of the arrow dependent on the size of the fish. I've made a matrix with for every fish i with lenght L(i) determines color(i)
(if L(i)<0.5
color(i)='b';

etc)

how do I know plot this using quiver3? I've tried multiple things, but nothing seems to work.

Thanks in advance!

Lisette
From: us on
"Lisette de Boer" <lisettede_boer(a)hotmail.com> wrote in message <hiclud$fce$1(a)fred.mathworks.com>...
> Hallo,
>
> I'm simulating fish schooling in matlab, using quiver3. I would like to make the color of the arrow dependent on the size of the fish. I've made a matrix with for every fish i with lenght L(i) determines color(i)
> (if L(i)<0.5
> color(i)='b';
>
> etc)
>
> how do I know plot this using quiver3? I've tried multiple things, but nothing seems to work.
>
> Thanks in advance!
>
> Lisette

one of the solutions

% the data
% - modified from HELP QUIVER3
[x,y]=meshgrid(-2:.5:2,-2:.5:2);
z=x .*exp(-x.^2-y.^2);
[u,v,w]=surfnorm(x,y,z);
% the engine
tf=u<0; % <- color is different for U<0 and U>=0
% the result
quiver3(x(tf),y(tf),z(tf),u(tf),v(tf),w(tf),'color',[1,0,0],'linewidth',.5);
hold on;
tf=~tf;
quiver3(x(tf),y(tf),z(tf),u(tf),v(tf),w(tf),'color',[0,1,0],'linewidth',1);
surf(x,y,z);
colormap(bone);

us
From: Lisette de Boer on
"us " <us(a)neurol.unizh.ch> wrote in message <hidi9r$fh8$1(a)fred.mathworks.com>...
> "Lisette de Boer" <lisettede_boer(a)hotmail.com> wrote in message <hiclud$fce$1(a)fred.mathworks.com>...
> > Hallo,
> >
> > I'm simulating fish schooling in matlab, using quiver3. I would like to make the color of the arrow dependent on the size of the fish. I've made a matrix with for every fish i with lenght L(i) determines color(i)
> > (if L(i)<0.5
> > color(i)='b';
> >
> > etc)
> >
> > how do I know plot this using quiver3? I've tried multiple things, but nothing seems to work.
> >
> > Thanks in advance!
> >
> > Lisette
>
> one of the solutions
>
> % the data
> % - modified from HELP QUIVER3
> [x,y]=meshgrid(-2:.5:2,-2:.5:2);
> z=x .*exp(-x.^2-y.^2);
> [u,v,w]=surfnorm(x,y,z);
> % the engine
> tf=u<0; % <- color is different for U<0 and U>=0
> % the result
> quiver3(x(tf),y(tf),z(tf),u(tf),v(tf),w(tf),'color',[1,0,0],'linewidth',.5);
> hold on;
> tf=~tf;
> quiver3(x(tf),y(tf),z(tf),u(tf),v(tf),w(tf),'color',[0,1,0],'linewidth',1);
> surf(x,y,z);
> colormap(bone);
>
> us

I think my problem is a bit different, since i want to plot different colors at the same time. I've tried this, but i don't get an output then.

Is it possible to determine the color first, and than use this vector in quiver?

thanks
From: us on
"Lisette de Boer" <lisettede_boer(a)hotmail.com> wrote in message <hif2gv$gg2$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <hidi9r$fh8$1(a)fred.mathworks.com>...
> > "Lisette de Boer" <lisettede_boer(a)hotmail.com> wrote in message <hiclud$fce$1(a)fred.mathworks.com>...
> > > Hallo,
> > >
> > > I'm simulating fish schooling in matlab, using quiver3. I would like to make the color of the arrow dependent on the size of the fish. I've made a matrix with for every fish i with lenght L(i) determines color(i)
> > > (if L(i)<0.5
> > > color(i)='b';
> > >
> > > etc)
> > >
> > > how do I know plot this using quiver3? I've tried multiple things, but nothing seems to work.
> > >
> > > Thanks in advance!
> > >
> > > Lisette
> >
> > one of the solutions
> >
> > % the data
> > % - modified from HELP QUIVER3
> > [x,y]=meshgrid(-2:.5:2,-2:.5:2);
> > z=x .*exp(-x.^2-y.^2);
> > [u,v,w]=surfnorm(x,y,z);
> > % the engine
> > tf=u<0; % <- color is different for U<0 and U>=0
> > % the result
> > quiver3(x(tf),y(tf),z(tf),u(tf),v(tf),w(tf),'color',[1,0,0],'linewidth',.5);
> > hold on;
> > tf=~tf;
> > quiver3(x(tf),y(tf),z(tf),u(tf),v(tf),w(tf),'color',[0,1,0],'linewidth',1);
> > surf(x,y,z);
> > colormap(bone);
> >
> > us
>
> I think my problem is a bit different, since i want to plot different colors at the same time. I've tried this, but i don't get an output then.
>
> Is it possible to determine the color first, and than use this vector in quiver?
>
> thanks

well, this works - and should do what you need...
did you copy/paste the snippet(?)...
did it yield an output(?)...
if(f) so: what does not work for you(?)...

us
From: Lisette de Boer on

> well, this works - and should do what you need...
> did you copy/paste the snippet(?)...
> did it yield an output(?)...
> if(f) so: what does not work for you(?)...
>
> us

Hi,

I did something wrong but now it works. One more question; how do I do this if i want more than 2 colors, so i want to make the distinction between L<0, 0<L<0.5 and 0.5<L<1?

thanks again!
 |  Next  |  Last
Pages: 1 2
Prev: Image Overlay using pcolor-Plots
Next: redundancies