Can someone please explain how to make this simple program from the Primer run - I am a beginner with MatLab

nsamples=5;
npoints=50;
for k=1:nsamples;
iterationString = ['Iteration # ', int2str(k)];
disp(iterationString)
currentData = rand(npoints,1);
sampleMean(k) = mean(currentData);
end
overallMean = mean(sampleMean);

Answers (1)

On the Home tab or Editor tab of the tool ribbon, select New Script. Then paste it in to the new window it creates. Dock the window with the little down arrow on its title bar. You can grab its title bar and drag it to other docked locations if you want.
Then type F5 or else click the green Run triangle on the Editor tab of the tool ribbon.
I did it and it works fine with no errors or warnings at all.

2 Comments

Thank you very much. I followed your instructions which are helpful but came across the same difficulty as I had been experiencing and this is the line I could not solve - Subscript indices must either be real positive integers or logicals. Can you please tell me how to do this?Many thanks

Sign in to comment.

Tags

Asked:

on 17 Dec 2015

Commented:

on 17 Dec 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!