MATLAB: Trying to make a function for summing up 3 numbers. Explaination below

MATLABmatlab functionnewstarter

Hello, I am trying to make a function that can split any type of number ( I am using Getdigits for that ) and sum the digits. I want the user to be able to input any digit number in a type of [x y z] and then be able to find if any of the numbers are odd. Unfortunately I am new to Matlab and I am not really able to make it work. Can anyone help me please. Thank you

Best Answer

the following answer is an alternative approach without using 'getdigits' function :
function [C,y]=sum3(x)
h=int2str(x);
N=length(h);
for n=1:N
C(n)=str2num(h(n));
end
y=sum(C);
Related Question