MATLAB: Please can some one explain

function

Hello
I was asked to make a function that returns an average by mean(), but the function takes a vector as value, so I tried writing so many functions. All give me an error when writing the Length part.
So please can someone tell me how to write the function with vector as value?

Best Answer

function theAverage = MyMeanFunction(myData)
theAverage = mean(myData(:));
This will take any shape of input data - vector, matrix, or multi-dimensional.