Karren
Posts:
15
Registered:
11/7/11
|
|
Re: Repeat Simulation
Posted:
Mar 20, 2012 12:23 AM
|
|
"Nasser M. Abbasi" <nma@12000.org> wrote in message <jk8c4l$di1$1@speranza.aioe.org>... > On 3/19/2012 4:58 PM, Karren wrote: > > >> -------------------------------- > >> [nRow,nCol]=size(V); > >> > >> SP_risk_neutral=zeros(nRow,1); %allocate space for simulation result > >> r=...; > >> d=...; > >> sigma=...; > >> T=...; > >> NRepl=...; > >> > >> for i=1:nRow > >> SP_risk_neutral(i)=Gen_SP_risk_neutral(V(i,2),r,d,sigma,T,V(i,1),NRepl); > >> end > >> ---------------------------- > > > > > > Thanks very much for the guide. It does help a lot but there is an error from the following > > > > for i = 1:nRow > > SP_risk_neutral(i)= Gen_SP_risk_neutral(V(i,2), r, d, sigma, dt, V(i,1),NRepl); > > end > > > > ERROR MESSAGE > > In an assignment A(I) = B, the number of elements in B and I must be the same. > > > > I do not know what your function Gen_SP_risk_neutral() returns. It > looks like it returns a matrix or a vector. > > You need to allocate space to store the result of your > Gen_SP_risk_neutral for all the simulation steps. > > i.e. allocate space (using the zeros function) for SP_risk_neutral > such that it matches what the function Gen_SP_risk_neutral returns. > > hth, > > --Nasser
The function returns a matrix, i.e. NRepl x NSteps for each simulation.
Karren
|
|