- #1
mmmboh
- 407
- 0
Hi, I am very new to matlab, this is actually the first time I am using it. I have to write a code for finding averages, right now I have "function av=average(x1,x2,x3,x4,x5)
% average(x1,x2,x3,x4,x5) returns the average of (x1,x2,x3,x4,x5)
av=(x1+x2+x3+x4+x5)/5;
return;"
This works just fine when there are 5 things to average, but I can't figure out how to make it work for n variables. Can someone help me please?
% average(x1,x2,x3,x4,x5) returns the average of (x1,x2,x3,x4,x5)
av=(x1+x2+x3+x4+x5)/5;
return;"
This works just fine when there are 5 things to average, but I can't figure out how to make it work for n variables. Can someone help me please?