ルンゲクッタ法の入力引数の不足について。
Afficher commentaires plus anciens
function xy = rk4(fun,x0,xe,h,y0)%関数、初期値、終端値、分割数、y初期値
x = linspace(x0,xe,h);%%h個の点、間隔は(xe-x0)/h
f = @fun(x);
y = zeros(1,h);
dx = (xe-x0)/h;
y(1) = y0;
Y=feval(f,x);
for k=2:h
k1 = h*Y(k);
k2 = h*feval(f,x(k)+k1./2);
k3 = h*feval(f,x(k)+k2./2); %%(Y(k)+k2.*dx./2)./(x(k)+dx./2);
k4 = h*feval(f,x(k)+k3);
y(k)=y(k-1)+(k1+2*k2+2*k3+k4).*dx/6;
end
cosを関数として入力した場合、入力引数が不足しています。
ある関数を入力すれば、その関数によってルンゲクッタ法を再現できるようにしたいのですが、うまく作ることができません。よろしくお願いします。
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur グラフィックス オブジェクトの識別 dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!