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

1 view (last 30 days)
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)

Image Analyst
Image Analyst on 17 Dec 2015
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
Robert Booth
Robert Booth on 17 Dec 2015
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.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!