Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Repeat Simulation
Replies: 14   Last Post: Jul 30, 2012 6:39 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Karren

Posts: 15
Registered: 11/7/11
Re: Repeat Simulation
Posted: Mar 18, 2012 11:43 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Nasser M. Abbasi" <nma@12000.org> wrote in message <jk5v6g$afk$1@speranza.aioe.org>...
> On 3/18/2012 6:54 PM, Karren wrote:
> >Can you please look at my code and provide further guide?
> >
> > function [ SP_risk_neutral ] = Gen_SP_risk_neutral(S0, r, d, sigma, T, NSteps,NRepl)

> ...
> > I tried to repeat the function/simulation as suggested but I failed.
> >Following is the code that I used.
> >
> > V = xlsread('parameters.xlsx');
> > for i = 1:length(V)
> > run Gen_SP_risk_neutral(V(i))
> > end
> >
> > Error message states that there is an error in line 3.
> >

>
> You can see that the function you are calling expects many
> arguments (I see 7 arguments). And in the loop you are calling it
> with one argument, which is V(i), which I do not know what it is,
> since I can't see what you read in there, or even if
> the read from excel is working or not, but it is
> just one argument.
>
> The loop example I gave you is just a prototype, and is meant
> as a guideline to what you need to do it.
>
> You need to read the parameters from your excel sheet, and
> write a loop which calls you other function correctly.
>
> good luck,
> --Nasser


Though I have 7 arguments, only 2 arguments change each time when a simulation ends. My function Gen_SP_risk_neutral is working well. The only problem is creating the loop to repeat the simulations.

What I have tried is to read the two parameters from excel using
V = xlsread('parameters.xlsx');

which gives me a matrix of 5 x 2 as follows:
NSteps S0
1858 15.72
1857 15.84
1856 15.46
1855 15.78
1854 15.50

Then I have to set up loops to repeat the simulations for the above parameters. But I failed.

How many loops do I need to create here? Do I need to break the matrix to 2 different vectors? Or can I create a loop for the matrix.

Sorry to disturb again. I'm stuck...

Thanks very much.

Karren



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.