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

- March 5th 2008, 09: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! - March 6th 2008, 10: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 - March 6th 2008, 04:11 PManon
Thanks so much for the reply - this is really helpful! :)