MATLAB程序设计:改进欧拉公式

clear;clc;close all;
syms x y 
f=exp(x^2);
x0=0; y0=0; % (x0 y0)为初值
h=0.5; N=4; 
xi=x0:h:x0+h*N; 
yi=zeros(1,N); yi(1)=y0; 
for k=1:N
yi(k+1)=yi(k)+h*subs(f,{x y}, {xi(k),yi(k)}); 
yi(k+1)=yi(k)+h/2*( subs(f,{x y}, {xi(k),yi(k)})+subs(f,{x y}, {xi(k+1),yi(k+1)} )); 
end
vpa( yi, 6)

你可能感兴趣的:(matlab,算法,人工智能)