Do not use the MATLAB functions or the matrix multiplication operator (*) or tra
ID: 1885057 • Letter: D
Question
Do not use the MATLAB functions or the matrix multiplication operator (*) or transpose operator (') for the following problem. You can use * to multiply scalars. 6. Let a and b be three-dimensional vectors that are entered from input statements. Write a MATLAB script that calculates: 1. the dot product between the two vectors; and 2. the cross product a × b. Do not use the built-in MATLAB functions. The output should be: The dot product of [xx.xx, xx.xx, xx.xx] and [xx.xx, xx.xx, xx.xx] is xx.xx. The cross product of [xx.xx, xx.xx, xx.xx] and [xx.xx, xx.xx, xx.xx] is [xx.xx, xx.xx, The cross product of vectors (a, a2, a3) and (b, b2, b;) can be calculated as:Explanation / Answer
a=input('enter vector a'); b=input('enter vector b'); adotb=[a(1)*b(1)+a(2)*b(2)+a(3)*b(3)]; acrossb=[a(2)*b(3)-a(3)*b(2) a(3)*b(1)-a(1)*b(3) a(1)*b(2)-b(1)*a(2)]; disp(adotb); disp(acrossb); >> source("dotncross.m") enter vector a> [1 2 3] enter vector b> [3 2 -1] 4 --> dot product -8 10 -4 --> Cross product
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.