%% Stochastic Interpolation Without Refinement
%% Specify the BM Model

mu    = [0.3; 0.4];
sigma = [0.2 -0.1; 0.1 -0.2];
rho   = [1 0.5; 0.5 1];
obj   = bm(mu,sigma,'Correlation',rho);

%
%% Simulate a single path from BM

rng default                 % make output reproducible
dt    = 1/250;  % 1 trading day = 1/250 years
[X,T] = simulate(obj,250,'DeltaTime',dt);

%
%% Interpolate into the simulated time series

t = ((T(1) + dt/2):(dt/2):(T(end) - dt/2));
x = interpolate(obj,t,X,'Times',T);

%
%% Plot the simulated and interpolated values

plot(T,X(:,1),'.-r',T,X(:,2),'.-b')
grid on;
hold on;
plot(t,x(:,1),'or',t,x(:,2),'ob')
hold off;
xlabel('Time (Years)')
ylabel('State')
title('Bi-Variate Brownian Motion: \rho = 0.5')
axis([0.4999 0.6001 0.25 0.4])

% Copyright 2015 The MathWorks, Inc.