Anyone know what is the function of matlab to find answer of my question?
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
更多回答(1 个)
Image Analyst
2013-4-1
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!