Simulate trajectories of CEV process

5 views (last 30 days)
Emilie M
Emilie M on 30 Apr 2017
Answered: Chaitral Date on 8 May 2017
I am trying to create a MATLAB code that simulates trajectories of a constant elasticity of variance process (CEV).
My code is below.
M = 5000; % number of trajectories of CEV process
N = 250; % number of steps in one trajectory
X0 = 100; % initial point
T = 1; % final time in years in trajectory
a = 0.7; % constant
dt = T/N; % time step
X(1:M,1) = X0;
for j = 1:M
for i = 2:N+1
X(j,i) = 0.02*X(j,i-1)*dt + 0.15*X(j,i-1)^a*sqrt(dt)*randn;
end
end
t = 0:dt:T;
plot(t,X(:,:));
However, when I run the code the following warning message appears,
Warning: Imaginary parts of complex X and/or Y arguments ignored In ConstantElasticyVariance (line 19)
and weird straight lines are shown in the plot.
What am I doing wrong?

Answers (1)

Chaitral Date
Chaitral Date on 8 May 2017
Use the below function to see the graph more clearly.
set(gca,'xscale','log');
I hope this helps.

Categories

Find more on Simulink 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!