Loers Antario
Loers Antario

Reputation: 1651

quiver3 returns vectors with incorrect length

I have a set of vectors

t = [ -1    -1     0
       1    -1     0
       1     1     0
      -1     1     0 ]

those vectors form a square when plotted sequentially (head to tail)

I am using the quiver3 instruction to obtain a plot of those vectors as follows:

quiver3(starts(:,1), starts(:,2), starts(:,3), t(:,1), t(:,2), t(:,3))

I calculated "starts" by cumulative sums of the matrix t and got the following result

starts = [ 0     0     0
          -1    -1     0
           0    -2     0
           1    -1     0]

All the values makes perfect sense and would give a square if plotted manually, but quiver3 returned the following plot

enter image description here enter image description here

Why aren't the vectors' heads touching the tails? how can I fix that?

Upvotes: 2

Views: 184

Answers (1)

Robert Seifert
Robert Seifert

Reputation: 25232

You need to set the AutoScaleFactor to 1:

t = [...
    -1    -1     0
     1    -1     0
     1     1     0
    -1     1     0]

starts = [...
     0     0     0
    -1    -1     0
     0    -2     0
     1    -1     0]

quiver3(starts(:,1), starts(:,2), starts(:,3), t(:,1), t(:,2), t(:,3), ...
        'AutoScaleFactor',1)

enter image description here

It is set to 0.9 by default as a whole vector field would look a little messy otherwise.


Edit: see how this works for you:

 starts = [ 0 0 0; -13 12 0]
 t = [ -13 12 0; -1 2 0]

 quiver3(starts(:,1), starts(:,2), starts(:,3), t(:,1), t(:,2), t(:,3), 0)
 view(0,90)

The 0 defines the fixed scale factor, 0 means no scaling. enter image description here

Upvotes: 3

Related Questions