%欧拉法解一阶常微分方程
% y'=xy^(1/3)
f = inline('x*y^(1/3)','x','y');
figure; hold on;
for h = [0.1 0.05 0.01] %三个步长
xleft = 1; %区域的左边界
xright = 5; %区域的右边界
xx = xleft:h:xright; %一系列离散的点
n = length(xx); %点的个数
y0 = 1;
Euler = y0;
for i = 2:n
Euler(i)=Euler(i-1)+h*f(xx(i-1),Euler(i-1));
end
plot(xx,Euler,'LineWidth',2);
end
%精确解
y = ((xx.^2+2)/3).^(3/2);
plot(xx,y,'r','LineWidth',2);
grid on;
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/574e9258d109b3de30f726decfbf6c81800a4c38?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
追问第三行是不是遗漏了什么啊 我在matlab上运行它说不正确啊
追答什么错误?
追问可能是我command语句输错了 你在command窗口输入的啥子嘛