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

16 次查看(过去 30 天)
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
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 ?
Jan
Jan 2017-3-13
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 个)

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by