How to project given vectors in matlab
4 次查看(过去 30 天)
显示 更早的评论
v1 = [1.12;2.10;7.03;4.15;6.13] v2 = [1;-1.01;1.02;-1.03;1.04]
I need to calculate projection of v1 onto v2 how would I code this into matlab?
1 个评论
John D'Errico
2017-7-1
编辑:John D'Errico
2017-7-1
A dot product.
https://math.oregonstate.edu/home/programs/undergrad/CalculusQuestStudyGuides/vcalc/dotprod/dotprod.html
help dot
You will need the norm of the vector v1.
help norm
回答(1 个)
James Tursa
2017-7-1
编辑:James Tursa
2017-7-1
E.g., see this link
https://en.wikipedia.org/wiki/Vector_projection
u = v2/norm(v2);
result = dot(v1,u)*u;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Software Development Tools 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!