Dot product question

조회 수: 6 (최근 30일)
Adam
Adam 2011년 9월 15일
New to the program and am trying to take the symbolic dot product of two matrices for a mechanical design course.
If: Syms cx cy h b a Ψ θ
B = [cx + b*cos(Ψ); cy + b*sin(Ψ)]
A = [a*cos(θ); a*sin(θ)]
C = (B-A)•(B-A) –h^(2) = 0
And a•a = ‖a‖2
Then ‖a‖ = √ a•a
So the magnitude of (B-A) is: ‖(B-A) ‖ = √ (B-A) •(B-A)
When I perform this calculation it returns the combined matrices with values raised to the ½ power and the additions of complex conjugates. Clearly there is an error with my process can anyone help me to see it and understand it?
The professor provided a vague example (not in matlab however) where: B = [g + b*cos(Ψ); 0 + b*sin(Ψ)] A = [a*cos(θ); a*sin(θ)]
C = (B-A)•(B-A) –h^(2) = 0
C = (2bg-2abcos(θ))cos(Ψ) – (2absin(θ))sin(Ψ) + (a^2 +b^2 +g^2 – h^2 -2agcos(θ)) =0
Thank you.

답변 (1개)

bym
bym 2011년 9월 15일
I assume you are calling from the Matlab command line
syms cx cy h b a psi theta real
B = [cx + b*cos(psi); cy + b*sin(psi)];
A = [a*cos(theta); a*sin(theta)];
C = feval(symengine,'linalg::scalarProduct',A-B,B-A);
C=C-h^2
simplify(C)
you may need to do some collecting of terms to get it the terms provided by your professor, but I am sure you will recognize it
HTH

Community Treasure Hunt

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

Start Hunting!

Translated by