computation on each column in matrix - projecting the Matrix onto a plane
조회 수: 2 (최근 30일)
이전 댓글 표시
I have this matrix R which has 10095 columns and three rows - meaning each column represents a coordinate x,y,z
I am wondering how I can operate on each column and save the result in a new matrix?
Here is my projection code, but p1 (the point to be projected) is just one of my 10095 points and I can not go repeating this by hand!
p0 = [0; 0; 0] %the point in my new plane, the one I am gonna project onto
N = [1,2,3]; %Normal to the plane which has the point p0
p1 = [1,90,0] %Just one of the points from the matrix R I used, but now I need p1 to be general for all the points
point_project = p1 + dot(p1-p0, N) * N; %here p1 would be column 1 then column 2 then column 3.... in my matrix R
댓글 수: 0
답변 (1개)
Ameer Hamza
2020년 10월 19일
편집: Ameer Hamza
2020년 10월 19일
Try this
p0 = [0; 0; 0]; %the point in my new plane, the one I am gonna project onto
N = [1,2,3].'; %Normal to the plane which has the point p0
p1 = rand(3, 10095); %Just one of the points from the matrix R I used, but now I need p1 to be general for all the points
point_project = p1 + dot(p1-p0, repmat(N, 1, 10095)) .* N; %here p1 would be column 1 then column 2 then column 3.... in my matrix R
I have changed N to a column vector.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!