ex6.m

来自「fokker-planck example」· M 代码 · 共 39 行

M
39
字号
dt=.1;b=0.2;randn('seed',717171)r=randn(100,1);t=zeros(100,1);w=zeros(100,1);w0=0;t(1)=1;w(1)=w0;for i=2:100  t(i)=i;  w(i)=w(i-1)+sqrt(dt)*r(i);end  %the exact solutionew=exp(b*w);  %the numerical solution with the Euler schemex0=1.0;x(1)=x0;for i=2:100  x(i)=x(i-1)+0.5*b*b*x(i-1)*dt+x(i-1)*b*sqrt(dt)*r(i);end   plot(t,ew,'-',t,x,'.-');title('Exact Solution and Euler Numerical Solution')xlabel('time t')ylabel('X(t)')legend('Exact','Numerical',0) 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?