How do I store all results from a Monte Carlo simulation? The output only shows the last entry. Any help would be appreciated - I'm a Matlab newbie and have been stuck on this for a while.

Thanks!

Printable View

- Mar 5th 2008, 08:54 PManonMatlab simulation help!
How do I store all results from a Monte Carlo simulation? The output only shows the last entry. Any help would be appreciated - I'm a Matlab newbie and have been stuck on this for a while.

Thanks! - Mar 6th 2008, 09:30 AMCaptainBlack
Presumably inside the function or whatever you have a loop something like:

Code:`function x=SomeFunc(nitert)`

for idx=1:nitert

x=some calculation of an instantation of a random variable X

end

Code:`function rv=SomeFunc(nitert)`

rv=zeros(1,nitert);

for idx=1:nitert

x=some calculation of an instantation of a random variable X

rv(idx)=x;

end

RonL - Mar 6th 2008, 03:11 PManon
Thanks so much for the reply - this is really helpful! :)