I have a function that calculates the average of two columns of a matrix. For example, if the following matrix is as follows:
inputMatrix = 1 2 5 3 9 4 6 2 3 2 4 4 3 9 1
... And my team:
outputVector = mean(inputArray(:,1:2))
... Then my conclusion:
outputVector = 3 4
The problem arises when my input matrix contains only one row (i.e. when it is a vector, not a matrix).
For example, input:
inputMatrix = 4 3 7 2 1
Gives output:
outputVector = 3.5000
I would like the same behavior to be supported regardless of the number of lines in the input. To clarify, the correct conclusion for the second example above should be:
outputVector = 4 3
source share