CS计算机代考程序代写 clear all;

clear all;
close all;

Delta_t=0.02;
t=0:Delta_t:10.0;

%Preallocating memory
x=zeros(size(t));

x(1)=1.0;
for n=1:length(t)-1
x(n+1)=x(n)+Delta_t*(i*2*x(n));
end

plot(t,imag(x),’ko-‘,’linewidth’,2,’markersize’,10)
hold on

tplot=0:0.01:10.0;
truesolution=@(t)(sin(2*t))
plot(tplot,truesolution(tplot),’b-‘,’linewidth’,2)
axis([0 10 -5 5])

xlabel(‘t’);
ylabel(‘x(t)’);
legend(‘Euler’,’True’);