Hi Zahra,
The calculation of mean is to be done in the inner loop, where as I see it is being done in the outer loop in your code. This is the reason for the errors. Please refer to the code below :
mean = [];
for i = 1 : 5
m = 0;
for j = 1 : 1000
s = 0;
r = randn(1);
s = s + r;
m = s / 1000;
end
mean(i) = m;
end
value = max(mean);
index = find(mean == max(mean));
disp(mean);
disp(value);
disp(index);