# plot vector using complex numbers

27 visualizaciones (últimos 30 días)
chirag rohit el 5 de En. de 2020
Respondida: Fabio Freschi el 5 de En. de 2020
I have array or matrix of complex numbers like this;
[-3+4i;-2+5i;1+3i;6+2i;-1-8i]
I want connect each point of abow matrix with 0+0i using line arrow (vector). Arrow starts form 0+0i and ends at -3+4i. Again in same plot, second arrow start from 0+0i and ends at -2+5i. Likewise i want to connet each number of above matrix with 0+0i using vector arrow with same color.
Right now i am using this code to plot. But it is taking long time to write this. Every time i have to saperate real and imaginary part and plot each vector individually.
p0=[0 0];
p1=[-3 4];
p2=[-2 5];
p3=[1 3]
p4=[6 2];
p5=[-1 -8]
vectarrow(p0,p1);hold on;
vectarrow(p0,p2);hold on;
vectarrow(p0,p3);hold on;
vectarrow(p0,p4);hold on;
vectarrow(p0,p5);hold off
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Fabio Freschi el 5 de En. de 2020
You can use compass or quiver
% your matrix
A = [-3+4i;-2+5i;1+3i;6+2i;-1-8i];
% with compass
figure
compass(real(A),imag(A));
% with quiver
figure
quiver(zeros(size(A,1),1),zeros(size(A,1),1),real(A),imag(A));
axis equal
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Vector Fields en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by