📄 ex6.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -