MATLAB: How to use input element of function in code

function

Let's suppose I have this function
function [mean,stdev] = stat(x,b)
n = length(x)
mean = sum(x)/n;
stdev = sqrt(sum((x-mean).^2/b));
and I call this function by
>> [mean stdev] = stat([12.7 45.4 98.9 26.6 53/1],400)
Is there any way I can use each element of input in my code lets suppose in my code I want to use sum which is equal to first element + second element (that is 12.7+45.4)
sum = input_element_1 + input_element_2
How can I do that?

Best Answer

Inside your function, just use y=x(1)+x(2). It is a good idea to check the size of x first.