Plot Vector using Plot3

2 views (last 30 days)
Jacque
Jacque on 13 Mar 2012
Hi guys,
I've calculated a vector using the cross product of 2 vectors and am curious how I can input this so that I can draw a plot.
How can I input it in a way that my i, j and k values will correspond to x, y and z values?
Thanks for any help

Answers (2)

Tom
Tom on 13 Mar 2012
Since vectors aren't really tied to points, you need to first specify a starting point for your vectors. If you want them to have common point, say (a,b,c). I would then construct x, y, z coordinate vectors like
x = i*t + a
y = j*t + b
z = k*t + c
where t is the parameter of the parametrized equations; it determines the length of your vectors. All that's left is plotting x, y and z.
  1 Comment
Jacque
Jacque on 13 Mar 2012
Sorry I wasn't quite sure how to use 't' (not the letter, but the function you're implying) so I've kinda got an answer that isn't right, but this seems closer.
What I've done now is:
Vperp = cross(AC,BD);
i = Vperp(1);
j = Vperp(2);
k = Vperp(3);
plot3(i,j,k,'k');
etc..
and even though this plot is much larger than plot it's running perp. too, i think it might be doing the right thing.
I have two vectors and I would like to plot the perp. plot starting from the intersect.
Is there a way I can specify the start position of a plot like this and have a line connected from the specified start to the vector, without using the hold function?
Thank you for your response, I will use it to spur some lateral thinking

Sign in to comment.


Tom
Tom on 14 Mar 2012
I would set t=0:0.05:1;, for instance.
I was thinking of using the hold function when plotting. Without it I would think you would have to be smart about the order that you plot the points (the order of the arrays). But if it looks like it's working (and is correct), it probably is. The length of the cross product always tends to be larger than the initial vectors. I would just divide the entire resultant vector by a factor of 2 or 3, whatever looked better.
  2 Comments
Jacque
Jacque on 17 Mar 2012
Sorry I took so long to respond to this. The problem with using hold is that the vector is changing at each iteration, so rather than having a straight arrow which shows the direction of the vector, I'm getting a wavey line over the plotted course of the vector's positions. Does this sound confusing? I found it hard to word it.
But thank you because you helped me understand that regardless of the factor the vector is multiplied by, the vector will still be acting in the same direction.
In MuPAD I can plot the vector as an arrow; is there a way I can either combine MuPAD with my code or can I simply plot an arrow in MATLAB?
Walter Roberson
Walter Roberson on 17 Mar 2012
annotation() can be used to plot arrows.
http://www.mathworks.com/help/techdoc/creating_plots/f0-33318.html

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!