How to plot a SDE $dx(t)=Ax(t)dt+Bx(t)dW(t)$ using Matlab, and how will the graph look like? [closed]

Could you please provide a full Matlab programme (which can be copied and pasted directly) that can plot the solution to the stochastic differential equation (SDE) $dx(t)=Ax(t)dt+Bx(t)dW(t)$, (where $x(t)$ is plotted as vertical axis, and time t is plotted as horizontal axis), where both A and B are given 2*2 matrices(please give some appropriate numbers to fix matrix A and B for programming), W(t) is Ito type Brownian motion (BM). I am very curious about how to set the BM with Matlab. Must I use any package or tool box to handle this issue? In addition, shall we make any assumption about the setting of BM in Matlab, especially for its variance? Shall we set the variance to a fixed number like 1, or bigger number like 100 or 1000? Thank you very much.

closed as off-topic by астон вілла олоф мэллбэрг, Behrouz Maleki, Claude Leibovici, John B, E. JosephDec 8 '16 at 18:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is not about mathematics, within the scope defined in the help center." – астон вілла олоф мэллбэрг, Behrouz Maleki, Claude Leibovici, John B, E. Joseph
If this question can be reworded to fit the rules in the help center, please edit the question.

• Are A,B constant numbers ? – Khosrotash Dec 8 '16 at 10:48
• Yes they are constant matrices that are given. – H Hua Dec 8 '16 at 11:12
• It is stochastic field or yuor $t$ is one-dimensional? – kolobokish Dec 8 '16 at 11:37
• t is scalar. But x(t) is a vector, for example[x_1(t)', x_2(t)]' – H Hua Dec 8 '16 at 11:39

Every time you rum the program you will see a new figure (note that)

first thing you must do is "discretization"

for example see below:

$$dx_t=a.x_t dt+ b.x_t.dw_t\\ \Delta x_t=a.x_t .\Delta t +b.x_t.\Delta W_t \\ x_{i+1}-x_i=a.x_i.\Delta t_i +b.x_i.\Delta W_{t_i}\\$$ if partitions are equidistant ... $$\Delta t_t=\Delta t=\frac{T-t_0}{n}\\\Delta W=\sqrt{\Delta t}*randn$$ so you can code this form $$x(i+1)-x(i)=a*x(i)*\Delta t +b*x(i)*\sqrt{\Delta t}*randn\\$$

%dx(t)=ax(t)dt+bx(t)dW(t)
%for exaple a=2, b=0.5
t0=0;        %begin time
T=1;         %terminal time
n=100;       %number of steps
dt=(T-t0)/n  %set delta t
a=2;         %input a
b=0.5;       %input b
dw=zeros(1,n);
axis=[t0+dt:dt:T];
x=zeros(1,n);
x(1)=2;      %x(1)=x0=2  initial condition

for k=2:n
dw(k)=sqrt(dt)*randn;
x(k)=x(k-1)+a*x(k)*dt +b*x(k-1)*dw(k-1);
end

grid on
hold on
plot(axis,x)


this is 1st run of program

• I am considering a continuous-time case. Do you mean every continuous SDE must be transformed into discrete case? Thanks a lot!!! – H Hua Dec 8 '16 at 11:16
• Usually SDE's have not a closed form solution ,but your case has. when you are programing you must duscreet the timing to use "for i=..." – Khosrotash Dec 8 '16 at 11:21
• I put an example for 1dimenstion example . hpoe can help you – Khosrotash Dec 8 '16 at 11:22
• Please let me try. Thank you very much. If there is any more question, please forgive me to ask. I do appreciate your help! Many thanks! – H Hua Dec 8 '16 at 11:26
• I am working for a two dimension SDE ,and programing of it . – Khosrotash Dec 8 '16 at 11:28