Dot product question

10 views (last 30 days)
Adam
Adam on 15 Sep 2011
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.

Answers (1)

bym
bym on 15 Sep 2011
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!