Plot Vector using Plot3

조회 수: 4 (최근 30일)
Jacque
Jacque 2012년 3월 13일
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

답변 (2개)

Tom
Tom 2012년 3월 13일
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
Jacque
Jacque 2012년 3월 13일
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

댓글을 달려면 로그인하십시오.


Tom
Tom 2012년 3월 14일
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
Jacque
Jacque 2012년 3월 17일
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 2012년 3월 17일
annotation() can be used to plot arrows.
http://www.mathworks.com/help/techdoc/creating_plots/f0-33318.html

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D Function Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by