Borrar filtros
Borrar filtros

Anyone know what is the function of matlab to find answer of my question?

2 visualizaciones (últimos 30 días)
i have a matrix g=[a;b] and how can i calculate m=sqrt(a^2 + b^2)? i need to write this function in such a while loop.

Respuesta aceptada

Walter Roberson
Walter Roberson el 31 de Mzo. de 2013
m = norm(g);

Más respuestas (1)

Image Analyst
Image Analyst el 1 de Abr. de 2013
Alternatively, but a little more complicated:
m = hypot(g(1), g(2));
Not sure why you need it to be in a while loop, but if you do, and a and b are row vectors
k = 1
while k <= size(g, 2)
a = g(1, k);
b = g(2, k);
m(k) = hypot(a, b);
k = k + 1;
end

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by