%2d sde
%Euler-Murayama method

x1=0;x2=1; %initial condition
T=30; %time limit

dt=0.001;
t=[0:dt:T];
n=size(t);
n=n(2);

clf reset;
%axis equal;
Bmt = cumsum(sqrt(dt)*randn(2,n));
%plot(t,Bmt(1:n),'Color',[0 0 1]);
hold on;
   
%plot(t,0.5*(Bmt.^2-t),'Color',[0 1 0]); %check against explicit solition

x=zeros(2,n);
x(1,1)=x1; x(2,1)=x2; %set the initial cond.

for (j=2:1:n)
    x(:,j)=x(:,j-1)+fd(x(:,j-1))*dt+ff(x(:,j-1)).*(Bmt(:,j)-Bmt(:,j-1));
end
    
plot(x(1,:), x(2,:), 'Color',[1 0 0]);
hold on;
   
title('SDE');

hold off;

  