Pythagorean theorem with matrixs

조회 수: 9 (최근 30일)
Erik
Erik 2012년 11월 18일
Hi
If you have two matrix with the same size, how do you use Pythagorean theorem at each element with the same index in both of the matrixs? For example: M1=[1 2 3; 4 5 6] and M2=[4 5 6; 1 2 3]
I want the result to be like: M3=[sqrt(1^2+4^2) sqrt(2^2+5^2) sqrt(3^2+6^2);sqrt(4^2+1^2) sqrt(5^2+2^2) sqrt(6^2+3^2)]
I hope its clear :/
Anyone knows how I can do it?
  댓글 수: 1
Image Analyst
Image Analyst 2012년 11월 18일
What's wrong with that solution? Does it not meet your needs? If not, then say why not.

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

채택된 답변

Matt J
Matt J 2012년 11월 18일
M3=hypot(M1,M2);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by