how to add elements in matrix

조회 수: 1 (최근 30일)
hanish h
hanish h 2015년 5월 27일
답변: Star Strider 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