You need to learn to use vector or matrix, the essence of MATLAB.
Pre-allocate you p as p=.1:.1:.9; p will be a 1x9 vector, you can reference individual element as p(1), p(2), etc.
Pre-allocate avg=zeros(size(p)), avg will be a all-zero vector the same size as p. Go through your loop, calculate the value of avg that is corresponding to p.
Then you can use plot(p,avg). It will plot a curve.
Right now, you are plotting one dot at a time. Since you have the hold on, it shows all the dots.
Add a semi-colon ";" at the end of each line, it will prevent the echo in the MATLAB Command Window, which slows down the program quite a lot.
Best Answer