how to add elements in matrix

1 Ansicht (letzte 30 Tage)
hanish h
hanish h am 27 Mai 2015
Beantwortet: Star Strider am 27 Mai 2015
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'

Antworten (2)

Nobel Mondal
Nobel Mondal am 27 Mai 2015
a = [2 6; 5 6];
result = sum(a');
  1 Kommentar
hanish h
hanish h am 27 Mai 2015
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'

Melden Sie sich an, um zu kommentieren.


Star Strider
Star Strider am 27 Mai 2015
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.)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by