MATLAB: I would like to get the average of some data only if the sample size is larger than two.

Hello,
I would like to get the average of some data only if the size of the sample is larger than two. So, if the sample size is smaller or equal to two, then it will not average. Thanks in advance.

Best Answer

  • if numel(x) > 2
    mean_x = mean(x);
    end