I am trying to plot the outputs of a function in my main through a For loop. I define the function (ballMC) in a separate m-file, and then call it to my main with specified inputs defined through the For loop. I tried to map the results of the For loop into an array, but I ended up getting the following message 'Array indices must be positive integers or logical values.' In the two lines of code before ending the loop. Any insight would be very much appreciated.
My code is as follows
n=2 Resultsestimate= zeros(50,1, 'double'); Resultshalfwidth =zeros(50,1, 'double'); for Nreps=logspace(1,6); [estimate, halfwidth]=ballMC(Nreps,n); Resultsestimate(Nreps)= estimate; Resultshalfwidth(Nreps)= halfwidth; end figure(1) plot(Nreps,Resultsestimate) figure(2) plot(Nreps,Resultshalfwidth)
Best Answer