Reputation: 127
I believe that therre is a simple answer but I have not found it. I want to compute statistics for an array (max, min, mean, median, std) in other way than:
max = max(array)
min = min(array)
mean = mean(array)
median = median(array)
std = std(array
because (as I believe) it would go through the array every single time at least once. I am hoping that there is some function like
[max, min, mean, median, std,...] = stat(array)
similar to the R function
summary(Array) #R code
or to the stata command
des //stata
What function should I use in matlab?
Upvotes: 1
Views: 2816
Reputation: 24127
Here's a function that does it:
function [maxout, minout, meanout, medianout, stdout] = summary(array)
maxout = max(array);
minout = min(array);
meanout = mean(array);
medianout = median(array);
stdout = std(array);
Just copy that, save it to a file on your path called summary.m
, and you should be good to go.
Upvotes: 1