Why do I get an error in this function and how to solve it?
Show older comments
function r=OU_SAMPLE (n,dt,beta,theta,sig,r0);
t(1)=0;
x(1)=theta-r0;
r(1)=r0;
for i=1:n-1;
t(i+1)=i*dt;
v=(exp(2*beta*t(i+1))-exp(2*beta*t(i)))*(2*beta)^(-1);
x(i+1)=x(i)-sig*normrnd(0,sqrt(v));
r(i+1)=theta-exp(-beta*t(i+1))*x(i+1);
end;
end
function r=OU_SAMPLE (n,dt,beta,theta,sig,r0);
↑
Error: Function definition not supported in this context. Create functions in code file.
Accepted Answer
More Answers (0)
Categories
Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!