필터 지우기
필터 지우기

Subtracting one column in matrix 1 from each column in matrix 2

조회 수: 2 (최근 30일)
Hi, I have to matrix (M_1, size 90x31 and M_2, size 90x130), i would like to subtract one column in matrix M_1 from each column in matrix M_2 and repeat this for each columns in matrix M_1 (31 times), and the result is a matrix ( there are 31 rows and 130 columns. Any ideas?
Thank you in advance.
  댓글 수: 4
Image Analyst
Image Analyst 2021년 12월 16일
What do the rows and columns represent? Do you have a 90 or 130 dimensional space? Or is each column just the location, like the x value along a number line? Have you seen pdist2() in the Stats toolbox?
Pawel Szczepanowski
Pawel Szczepanowski 2021년 12월 17일
each column in M_1 is a column vector of picture (picture is reshaped) is the same with martix M_2. I'd like to calculate euclideus distance between first column vector form M_1 and all column vectors in M_2 and repeat it with all column in M_1.

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

채택된 답변

Torsten
Torsten 2021년 12월 16일
편집: Torsten 2021년 12월 16일
Dist = vecnorm(bsxfun(@minus,M_2,M_1(:,1)));
for i=2:31
Dist = vertcat(Dist,vecnorm(bsxfun(@minus,M_2,M_1(:,i))));
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by