Hi everyone! My question is: how can i project an element on a straight line? In other words, i have a matrix(nx2) that represent my element and a matrix(2x2) that represent my straight line, how can i project that element on that line? Is there a function? Thx in advance! :)

댓글 수: 2

Matt J
Matt J 2012년 9월 29일
Explain how an nx2 matrix represent a (single?) element to be projected. Is each row a coordinate in 2D? And if so, how does a 2x2 matrix represents a straight line? In 2D, only 2 parameters are required to represent a line, not a 2x2 matrix.
Gimmy
Gimmy 2012년 9월 29일
Thx for the response! I mean that i have a class of 5 elements: X1 = [4 2;2 4;2 3;3 6;4 4]; which i represent using: scatter(X1(:,1),X1(:,2),'r'); and i have another vector: W1=[0,9087;0,4172] that i represent like a line using: t=20; w1=t.*W1'; new_w1=cat(1,w1,W1'); plot(new_w1(:,1),new_w1(:,2),'g'); And now i wonder to project the point in X1 on to the line new_w1. This image could help you: http://www.dtreg.com/LdaGoodBad.jpg
Thx in advance :)

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

 채택된 답변

Matt J
Matt J 2012년 9월 30일
편집: Matt J 2012년 9월 30일

0 개 추천

In your example, the line new_w1 is going through the origin. I'll assume that to be the case here.
In general, if you want to project X1 onto the line through the origin t*d where d is the direction vector of the line, you would do
projections = X1*d(:)*d(:).'/norm(d)^2

댓글 수: 2

Gimmy
Gimmy 2012년 9월 30일
Thx for the answer! However i've found this method yet, but i think that this is the "orthogonal projection" of the points X1 on the line W1, but i would like the "perpendicular projection" of the points in X1 on W1, how can i have this one?
Matt J
Matt J 2012년 10월 1일
I'm not aware of the distinction between "orthogonal projection" and "perpendicular projection".

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

추가 답변 (0개)

카테고리

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

질문:

2012년 9월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by