Differentialgleichung mit Matlab

Gast #1233111
Lesenswert?

ich habe was implementiert: Z.B: ich möchte jetzt als plot darstellen. 
Normal komme ich aus " C programmierung Ecke " , aber ich muss jetzt 
matlab programmieren. Und ich kann matlab nicht so gut.

function [res,err] = RK(a,ya,b,h_0,acc,eps);
fulfils dy/dx=f(x,y)
inc=1;
err=0;
x(inc)=a;
y(inc)=ya;
h=h_0;
inc=2;
x(inc),y(inc),y_old,err_step] = RKStep(x,y,h);
while x(inc)<b
tol=acc*sqrt(h/(b-a))+eps*y(inc)*sqrt(h/(b-a));
inc=inc+1;
if err_step>2*tol
h=h/2;
if h > (b-x(inc-1));
h = b-x(inc-1);
end
inc=inc-1;
[x(inc),y(inc),y_old,err_step] = RKStep(x(inc-1),y_old,h);
else
err=sqrt(err^2+err_step^2);
h_old=h;
h=0.95*(tol/err_step)^0.25*h;
if h>2*h_old
h=2*h_old;
if h > (b-x(inc-1));
h = b-x(inc-1);
end
[x(inc),y(inc),y_old,err_step] = RKStep(x(inc-1),y(inc-1),h);
else
if h > (b-x(inc-1));
h = b-x(inc-1);
end
[x(inc),y(inc),y_old,err_step] = RKStep(x(inc-1),y(inc-1),h);
end

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren