how to add elements in matrix

1 次查看(过去 30 天)
hanish h
hanish h 2015-5-27
actually my output argument is ab
function c=x(ab)
c=sqrt(a^2+b^2);
end
x(3 4)
i want the answer 5
i dont know what is im doin wrong in here
i want to know how to seperate or summing 'ab'

回答(2 个)

Nobel Mondal
Nobel Mondal 2015-5-27
a = [2 6; 5 6];
result = sum(a');
  1 个评论
hanish h
hanish h 2015-5-27
actually my output argument is ab
function c=x(ab)
c=sqrt(a^2+b^2);
end
x(3 4)
i want the answer 5
i dont know what is im doin wrong in here
i want to know how to seperate or summing 'ab'

请先登录,再进行评论。


Star Strider
Star Strider 2015-5-27
You need to put a comma between the arguments to your function:
function c=x(a,b)
and then the call to it would be:
x(3,4)
(You can use the built-in hypot function if you do not want to code your own version.)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by