Hello, I want to find the dot product of this two vector. Can anyone help me in the simple way
A=[c1 -s1 0
s1 c1 0
0 0 1]
N= [n1
n2
n3]

댓글 수: 4

the cyclist
the cyclist 2023년 8월 27일
"A" is not a vector. It is a matrix. You cannot take the dot product of a matrix and a vector.
Maybe you mean that you just want the matrix product? Or maybe you want the dot product of N with each column of A?
You need to clarify your question.
Syazana
Syazana 2023년 8월 27일
Here is the table of cosine which contain vector n1,n2,n3 and a1,a2,a3
Let's say if vector n1 x vector a1, I want the answer to be c1
Is ‘a1’ supposed to be ‘A(1,:)’ or ‘A(:,1)’?
Experiment with these options —
syms c1 n1 n2 n3 s1 real
A = [c1 -s1 0; s1 c1 0; 0 0 1];
N = [n1; n2; n3];
An = A * N % Original 'A'
An = 
AtN = A' * N % Transposed 'A'
AtN = 
.
Syazana
Syazana 2023년 8월 27일
편집: Syazana 2023년 8월 27일
Ok. Thank you so much. I change the N=[a1,a2,a3] and im using the first answer. Already got the answer. but how to set the coding if a3.n2 the answer will be in scalar which is 0 and if a3.n3 the answer will be 1. In the other words, if the vector multiply by the same vector the answer is 1 if not the answer will be 0

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

 채택된 답변

David Goodmanson
David Goodmanson 2023년 8월 28일
편집: David Goodmanson 2023년 8월 28일

0 개 추천

Hello Syazana
syms c1 s1 n1 n2 n3 a1 a2 a3 real
A = [c1 -s1 0; s1 c1 0; 0 0 1]
A =
[c1, -s1, 0]
[s1, c1, 0]
[ 0, 0, 1]
a1 = [1 0 0]'; % all of these are column vectors
a2 = [0 1 0]';
a3 = [0 0 1]';
n1 = [1 0 0]';
n2 = [0 1 0]';
n3 = [0 0 1]';
n1'*A*a1 % n1' is a row vector
ans = c1
n2'*A*a1 % A(2,1)
ans = s1
n1'*A*a2 % A(1,2)
ans = -s1
n3'*A*a3
ans = 1
As you can see, n1',n2', or n3' select out the row of A, and a1,a2, or a3 select out the column of A. As indicated in two comments above, the typograpy allows you to directly read off the resulting element of A. Doing the matrix multiplication by hand on a couple of examples will convince you how this works.

추가 답변 (1개)

Star Strider
Star Strider 2023년 8월 27일

0 개 추천

My pleasure!
‘... how to set the coding if a3.n2 the answer will be in scalar which is 0 and if a3.n3 the answer will be 1 ...’
If you changed ‘N’ to:
N=[a1,a2,a3]
and unless ‘A’ changed to something else as well (and was not posted), the ‘n’ elements no longer exist, so I am now lost.
syms a1 a2 a3 c1 s1 real
A = [c1 -s1 0; s1 c1 0; 0 0 1];
N = [a1; a2; a3];
An = A * N % Original 'A'
An = 
In any event, to change symbolic variables to something else, use the subs function.
.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2023년 8월 27일

편집:

2023년 8월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by