Question- Write a function called matrixsummary that takes in one argument, a matrix or a vector, and returns four output values - the sum, mean, max and min of all the values in the matrix or vector.
Do not use Matlab's built-in functions to accomplish this task - instead you should use nested for loops to traverse the entire vector or matrix one element at a time.
You should keep track of the sum, max and min each time you traverse an element. The mean can be computed after you have traversed the whole matrix or vector.
Here is sample output below:
>> v = [ 1, 10, 12, 15, 5, 2, 3 ];
>> [sum,mean,max,min] = matrixsummary(v)
sum = 48
mean = 6.8571
max = 1
min = 15
Prepare a function called matrixsummary that takes in one argument, a matrix or a vector, and returns four output values.
I was hoping someone can describe on a high level as to how this happens.