%% Simulate Merton Jump Diffusion Sample Paths by Euler Approximation
% Create a merton object.

AssetPrice = 80;
            Return = 0.03;
            Sigma = 0.16;
            JumpMean = 0.02;
            JumpVol = 0.08;
            JumpFreq = 2;
            
            mertonObj = merton(Return,Sigma,JumpFreq,JumpMean,JumpVol,...
                'startstat',AssetPrice)

% Use simByEuler to simulate NTrials sample paths of NVars correlated state variables driven by NBrowns Brownian motion sources of risk and NJumps compound Poisson processes representing the arrivals of important events over NPeriods consecutive observation periods. The function simByEuler approximates a continuous-time Merton jump diffusion process by the Euler approach.

NPeriods = 2;
[Paths,Times,Z,N] = simByEuler(mertonObj,NPeriods)

% Paths is a 3-by-1 matrix. The only column is the path of the simulated AssetPrice. The output Z is a series of matrices used to generate the Brownian motion vector. The output N is a series of matrices used to generate jump vectors.
% Copyright 2019 The MathWorks, Inc.