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:
plotting vectors

Subject: plotting vectors

From: Snow White

Date: 12 Aug, 2011 12:13:14

Message: 1 of 7

Hello,

Can anyone tell me is there a way of plotting vectors with arrow heads of a matrix as follows:

[1+1.1i 2+3i 5+8i;6+1.1i 20+0.3i 1.5+8i]

And each element of the matrix being plotted at its location for example 1+1.1i at (1,1) and so on...

Bye

Subject: plotting vectors

From: Manos K

Date: 19 Aug, 2011 12:08:08

Message: 2 of 7

"Snow White" wrote in message <j235cq$sib$1@newscl01ah.mathworks.com>...
> Hello,
>
> Can anyone tell me is there a way of plotting vectors with arrow heads of a matrix as follows:
>
> [1+1.1i 2+3i 5+8i;6+1.1i 20+0.3i 1.5+8i]
>
> And each element of the matrix being plotted at its location for example 1+1.1i at (1,1) and so on...
>
> Bye

Hi,

You can try this function:

http://www.mathworks.com/matlabcentral/fileexchange/3345-plot-arrowhead

To make a pair of coordinates from your real/complex pairs you can try this:

x = real(....);
y = imag(...);

or something along those lines.

HTH
Manos

Subject: plotting vectors

From: Snow White

Date: 19 Aug, 2011 14:20:12

Message: 3 of 7

"Manos K" wrote in message <j2ljn8$p0i$1@newscl01ah.mathworks.com>...
> "Snow White" wrote in message <j235cq$sib$1@newscl01ah.mathworks.com>...
> > Hello,
> >
> > Can anyone tell me is there a way of plotting vectors with arrow heads of a matrix as follows:
> >
> > [1+1.1i 2+3i 5+8i;6+1.1i 20+0.3i 1.5+8i]
> >
> > And each element of the matrix being plotted at its location for example 1+1.1i at (1,1) and so on...
> >
> > Bye
>
> Hi,
>
> You can try this function:
>
> http://www.mathworks.com/matlabcentral/fileexchange/3345-plot-arrowhead
>
> To make a pair of coordinates from your real/complex pairs you can try this:
>
> x = real(....);
> y = imag(...);
>
> or something along those lines.
>
> HTH
> Manos

I tried this but it does not work. Can u plz suggest another solution?

Subject: plotting vectors

From: Manos K

Date: 19 Aug, 2011 15:31:09

Message: 4 of 7

"Snow White" wrote in message <j2lres$mqb$1@newscl01ah.mathworks.com>...
> "Manos K" wrote in message <j2ljn8$p0i$1@newscl01ah.mathworks.com>...
> > "Snow White" wrote in message <j235cq$sib$1@newscl01ah.mathworks.com>...
> > > Hello,
> > >
> > > Can anyone tell me is there a way of plotting vectors with arrow heads of a matrix as follows:
> > >
> > > [1+1.1i 2+3i 5+8i;6+1.1i 20+0.3i 1.5+8i]
> > >
> > > And each element of the matrix being plotted at its location for example 1+1.1i at (1,1) and so on...
> > >
> > > Bye
> >
> > Hi,
> >
> > You can try this function:
> >
> > http://www.mathworks.com/matlabcentral/fileexchange/3345-plot-arrowhead
> >
> > To make a pair of coordinates from your real/complex pairs you can try this:
> >
> > x = real(....);
> > y = imag(...);
> >
> > or something along those lines.
> >
> > HTH
> > Manos
>
> I tried this but it does not work. Can u plz suggest another solution?

Sure,

However, you need to show me what you've done so far, and tell me which part of the above doesn't work.

Manos

Subject: plotting vectors

From: Snow White

Date: 19 Aug, 2011 16:14:09

Message: 5 of 7

"Manos K" wrote in message <j2lvjt$804$1@newscl01ah.mathworks.com>...
> "Snow White" wrote in message <j2lres$mqb$1@newscl01ah.mathworks.com>...
> > "Manos K" wrote in message <j2ljn8$p0i$1@newscl01ah.mathworks.com>...
> > > "Snow White" wrote in message <j235cq$sib$1@newscl01ah.mathworks.com>...
> > > > Hello,
> > > >
> > > > Can anyone tell me is there a way of plotting vectors with arrow heads of a matrix as follows:
> > > >
> > > > [1+1.1i 2+3i 5+8i;6+1.1i 20+0.3i 1.5+8i]
> > > >
> > > > And each element of the matrix being plotted at its location for example 1+1.1i at (1,1) and so on...
> > > >
> > > > Bye
> > >
> > > Hi,
> > >
> > > You can try this function:
> > >
> > > http://www.mathworks.com/matlabcentral/fileexchange/3345-plot-arrowhead
> > >
> > > To make a pair of coordinates from your real/complex pairs you can try this:
> > >
> > > x = real(....);
> > > y = imag(...);
> > >
> > > or something along those lines.
> > >
> > > HTH
> > > Manos
> >
> > I tried this but it does not work. Can u plz suggest another solution?
>
> Sure,
>
> However, you need to show me what you've done so far, and tell me which part of the above doesn't work.
>
> Manos

I have done as follows:
 a=[1+1.1i 2+3i 5+8i;6+1.1i 20+0.3i 1.5+8i];
x=real(a);
y=imag(a);

x1=[1 2 3;4 5 6]
y1=[1 2 3;4 5 6]
handles = plot_arrow( x1,y1,x,y1,'color',[0.5 0.5 0.5] )

??? Error using ==> plus
Matrix dimensions must agree.

Error in ==> plot_arrow at 75
teta = atan( (y2-y1)/den ) + pi*(x2<x1) - pi/2; % angle of arrow

I want the real and imaginary parts in different colours

Subject: plotting vectors

From: Manos K

Date: 19 Aug, 2011 17:41:10

Message: 6 of 7

"Snow White" wrote in message <j2m24h$gf0$1@newscl01ah.mathworks.com>...
> "Manos K" wrote in message <j2lvjt$804$1@newscl01ah.mathworks.com>...
> > "Snow White" wrote in message <j2lres$mqb$1@newscl01ah.mathworks.com>...
> > > "Manos K" wrote in message <j2ljn8$p0i$1@newscl01ah.mathworks.com>...
> > > > "Snow White" wrote in message <j235cq$sib$1@newscl01ah.mathworks.com>...
> > > > > Hello,
> > > > >
> > > > > Can anyone tell me is there a way of plotting vectors with arrow heads of a matrix as follows:
> > > > >
> > > > > [1+1.1i 2+3i 5+8i;6+1.1i 20+0.3i 1.5+8i]
> > > > >
> > > > > And each element of the matrix being plotted at its location for example 1+1.1i at (1,1) and so on...
> > > > >
> > > > > Bye
> > > >
> > > > Hi,
> > > >
> > > > You can try this function:
> > > >
> > > > http://www.mathworks.com/matlabcentral/fileexchange/3345-plot-arrowhead
> > > >
> > > > To make a pair of coordinates from your real/complex pairs you can try this:
> > > >
> > > > x = real(....);
> > > > y = imag(...);
> > > >
> > > > or something along those lines.
> > > >
> > > > HTH
> > > > Manos
> > >
> > > I tried this but it does not work. Can u plz suggest another solution?
> >
> > Sure,
> >
> > However, you need to show me what you've done so far, and tell me which part of the above doesn't work.
> >
> > Manos
>
> I have done as follows:
> a=[1+1.1i 2+3i 5+8i;6+1.1i 20+0.3i 1.5+8i];
> x=real(a);
> y=imag(a);
>
> x1=[1 2 3;4 5 6]
> y1=[1 2 3;4 5 6]
> handles = plot_arrow( x1,y1,x,y1,'color',[0.5 0.5 0.5] )
>
> ??? Error using ==> plus
> Matrix dimensions must agree.
>
> Error in ==> plot_arrow at 75
> teta = atan( (y2-y1)/den ) + pi*(x2<x1) - pi/2; % angle of arrow
>
> I want the real and imaginary parts in different colours

 You are doing a few things wrong. For example what's the point of matrices x1 and y1?
Check your code carefuly, and you ll figure it out.

Manos

Subject: plotting vectors

From: Snow White

Date: 19 Aug, 2011 21:10:09

Message: 7 of 7

"Manos K" wrote in message <j2m77m$4cq$1@newscl01ah.mathworks.com>...
> "Snow White" wrote in message <j2m24h$gf0$1@newscl01ah.mathworks.com>...
> > "Manos K" wrote in message <j2lvjt$804$1@newscl01ah.mathworks.com>...
> > > "Snow White" wrote in message <j2lres$mqb$1@newscl01ah.mathworks.com>...
> > > > "Manos K" wrote in message <j2ljn8$p0i$1@newscl01ah.mathworks.com>...
> > > > > "Snow White" wrote in message <j235cq$sib$1@newscl01ah.mathworks.com>...
> > > > > > Hello,
> > > > > >
> > > > > > Can anyone tell me is there a way of plotting vectors with arrow heads of a matrix as follows:
> > > > > >
> > > > > > [1+1.1i 2+3i 5+8i;6+1.1i 20+0.3i 1.5+8i]
> > > > > >
> > > > > > And each element of the matrix being plotted at its location for example 1+1.1i at (1,1) and so on...
> > > > > >
> > > > > > Bye
> > > > >
> > > > > Hi,
> > > > >
> > > > > You can try this function:
> > > > >
> > > > > http://www.mathworks.com/matlabcentral/fileexchange/3345-plot-arrowhead
> > > > >
> > > > > To make a pair of coordinates from your real/complex pairs you can try this:
> > > > >
> > > > > x = real(....);
> > > > > y = imag(...);
> > > > >
> > > > > or something along those lines.
> > > > >
> > > > > HTH
> > > > > Manos
> > > >
> > > > I tried this but it does not work. Can u plz suggest another solution?
> > >
> > > Sure,
> > >
> > > However, you need to show me what you've done so far, and tell me which part of the above doesn't work.
> > >
> > > Manos
> >
> > I have done as follows:
> > a=[1+1.1i 2+3i 5+8i;6+1.1i 20+0.3i 1.5+8i];
> > x=real(a);
> > y=imag(a);
> >
> > x1=[1 2 3;4 5 6]
> > y1=[1 2 3;4 5 6]
> > handles = plot_arrow( x1,y1,x,y,'color',[0.5 0.5 0.5] )
> >
> > ??? Error using ==> plus
> > Matrix dimensions must agree.
> >
> > Error in ==> plot_arrow at 75
> > teta = atan( (y2-y1)/den ) + pi*(x2<x1) - pi/2; % angle of arrow
> >
> > I want the real and imaginary parts in different colours
>
> You are doing a few things wrong. For example what's the point of matrices x1 and y1?
> Check your code carefuly, and you ll figure it out.
>
> Manos

I am using x1 and y1 because these values have to be passed to the function, as the starting point.

Tags for 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