Stochastic Differential Equations and simulation

조회 수: 12 (최근 30일)
Mari Alqarni
Mari Alqarni 2016년 2월 9일
I am working on stochastic differential equations for the first time. I am looking to simulate and solve a stochastic differential equations in two dimensions.
The model is as follows:
dp=F(t,p)dt+G(t,p)dW(t) where:
p is a 2-by-1 vector: p=(theta(t); phi(t)) F is a column vector: F=(sin(theta)+Psi* cos(phi); Psi* cot(theta)*sin(phi)) G is a 2-by-2 matrix: G=(D 0;0 D/sin(theta)) Psi is a parameter and D is the diffusion constant I wrote code as follows:
function MDL=gyro_2dim(Psi,D)
% State vector: p = [theta;phi];
F = @(t,p)[sin(p(1))+Psi.*cos(p(2))-D.*cot(p(1));
Psi.*cot(p(1)).*sin(p(2))]; % Drift
G = @(t,p)[D 0;
0 D./sin(p(1))]; % Diffusion
MDL = sde(F,G);
Then I call the function with the following script:
params.t0 = 0; % start time of simulation
params.tend = 20; % end time
params.dt =0.1; % time increment
D=0.1;
nPeriods=10; % # of simulated observations
Psi=1;
MDL=gyro_2dim(Psi,D);
[S,T,Z]=simulate(MDL, nPeriods,'DeltaTime',params.dt);
plot(T,S)
When I run the code, I receive this error message:
Drift rate invalid at initial conditions or inconsistent model dimensions.
Any idea how to fix this error?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Stochastic Differential Equation (SDE) Models에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by