Pythagorean theorem with matrixs

14 visualizaciones (últimos 30 días)
Erik
Erik el 18 de Nov. de 2012
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 comentario
Image Analyst
Image Analyst el 18 de Nov. de 2012
What's wrong with that solution? Does it not meet your needs? If not, then say why not.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 18 de Nov. de 2012
M3=hypot(M1,M2);

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by