How I can make a function projection (A,B)?

For example i would to project vector A to B.

댓글 수: 1

Jan
Jan 2017년 3월 12일
To me this sound like a homework question. Then please post, what you have tried so far.

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

 채택된 답변

Jan
Jan 2017년 3월 12일
편집: Jan 2017년 3월 13일

0 개 추천

The projection of a vector A onto a vector B has the same direction as the vector B, but a different length. When both are parallel, the length of A is not changed. When A and B are orthogonal, the resultung vector vanishes. You need the dot product to calculate this. The details are explained e.g. at Wiki: vector projection.
Please try this and post what you have done so far. If you have a specific question, you will get assistance here.

댓글 수: 2

Sara Jam
Sara Jam 2017년 3월 12일
편집: Jan 2017년 3월 13일
I made the function
P= projecton(A,B);
P= (dot(A,B)/norm(B)^2)*B
end
Is it correct ?
A function must start with the keyword "function":
function P = projection(A, B)
Then I'd insert a semicolon after the calculation to suppress the output to the command window. The calculations are correct.

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

추가 답변 (0개)

카테고리

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

질문:

2017년 3월 12일

댓글:

Jan
2017년 3월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by