Results 1 to 3 of 3

Math Help - Matlab simulation help!

  1. #1
    Newbie
    Joined
    Mar 2008
    Posts
    2

    Matlab 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!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by anon View Post
    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!
    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
    so what you do is something like:

    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
    then when called the function returns an array if instantations of the RV X.

    RonL
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Mar 2008
    Posts
    2
    Thanks so much for the reply - this is really helpful!
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Simulation help
    Posted in the Math Software Forum
    Replies: 0
    Last Post: February 11th 2010, 08:16 PM
  2. Replies: 0
    Last Post: December 15th 2009, 02:24 AM
  3. SImulation Help!!!!!!!!!!!!!!!!!!!
    Posted in the Statistics Forum
    Replies: 1
    Last Post: August 31st 2008, 04:20 AM
  4. Simulation
    Posted in the Statistics Forum
    Replies: 0
    Last Post: July 30th 2008, 11:20 PM
  5. Simulation
    Posted in the Statistics Forum
    Replies: 2
    Last Post: July 30th 2008, 01:13 AM

Search Tags


/mathhelpforum @mathhelpforum