%% Create an SDE Object
% Construct an SDE object obj to represent a univariate geometric Brownian Motion model of the form: $d{X_t} = 0.1{X_t}dt + 0.3{X_t}d{W_t}.
% Create drift and diffusion functions that are accessible by the common (t,X_{t}) interface:

F = @(t,X) 0.1 * X;
G = @(t,X) 0.3 * X;

%
% Pass the functions to sde to create an object (obj) of class sde:

obj = sde(F, G)    % dX = F(t,X)dt + G(t,X)dW

% obj displays like a MATLAB® structure, with the following information:
% The object's class
% A brief description of the object
% A summary of the dimensionality of the model
% The object's displayed parameters are as follows:
% StartTime: The initial observation time (real-valued scalar)
% StartState: The initial state vector (NVARS-by-1 column vector)
% Correlation: The correlation structure between Brownian process
% Drift: The drift-rate function F(t,X_{t})
% Diffusion: The diffusion-rate function G(t,X_{t})
% Simulation: The simulation method or function.
% Of these displayed parameters, only Drift and Diffusion are required inputs.
% The only exception to the (t, X_{t}) evaluation interface is Correlation. Specifically, when you enter Correlation as a function, the SDE engine assumes that it is a deterministic function of time, C(t). This restriction on Correlation as a deterministic function of time allows Cholesky factors to be computed and stored before the formal simulation. This inconsistency dramatically improves run-time performance for dynamic correlation structures. If Correlation is stochastic, you can also include it within the simulation architecture as part of a more general random number generation function.
% Copyright 2012 The MathWorks, Inc.