MATLAB: How to implement this formula in MatLab

formulaMATLAB

n is a constant = 100
x is an array of 100 rand elements

Best Answer

directly:
n=100;
x=rand(1,n);
s=std(x)
or with a loop:
n=100;
x=rand(1,n);
xmean=mean(x);
sumt=0;
for i=1:n
sumt=sumt+(x(i)-xmean)^2;
end
s=sqrt(sumt/(n-1))
Related Question