dimanche 30 août 2020

How to Plot a unit vector in matlab

I am trying to create 2 random points that have vectors that pass them in a random direction. Example shown below

figure 1

I tried creating 2 random points and 2 random unit vectors and using the function quiver to create the graph,

c = rand(1,2);
d = rand(1,2);

A = rand(2,1)-0.5;
B = rand(2,1)-0.5;
u = A/norm(A);
v = B/norm(B);

figure(3)
scatter(c,d)
quiver(c,d,u,v)

The quiver function doesnt really help and all I get is 2 points on a graph. Any help is appreciated.




Aucun commentaire:

Enregistrer un commentaire