Note that the indices in MATLAB are positive....ypu cannot use ii = p..you should use like below:
p=input('enter value p');
n=length(p);
suma=0;
for ii=1:length(p)
suma=suma+p(ii)
end
disp(suma)
M=(suma)/(n);
sumb=0;
for ii=1:length(p)
sumb=sumb+(p(ii)-M)^2
end
G=sumb;
variance=((G)^2)/n ;
sdeviation=(variance)^(0.5);
Cv=(100*sdeviation)/(M);
e=Cv/((n)^(0.5));
N=(Cv/e)^(2);
NR=round(N);
disp(NR)
Best Answer