How do solve four variables with one equation using Runge-kutta?
Ältere Kommentare anzeigen
clear
h= 0.001;
tfinal = 0.2;
t(1)=0; v(1)=3.388; lc(1)=0; z(1)=0;
f=@(t,v,lc,z) (((0.015*log((sqrt(0.015+z)+sqrt(z))/0.015^(3/2))+sqrt(z)*sqrt(z+0.015)-z+2*0.015*log(0.015+lc))/(2*log(0.015+lc)-2*log(0.015)))*9.81*z-998*(9.81*lc-0.5*v^2)*2*pi*(0.015^2)+0.11*9.81)/(0.11-1.38*pi*(0.015^2)*998*(log((sqrt((z-lc)^2)/sqrt((0.015^2)+(z-lc)^2)))-0.015))
for i=1:ceil(tfinal / h)
t(i+1)=t(i)+h;
k1=h*f(t(i),v(i),lc(i),z(i));
k2=h*f(t(i)+0.5*h, v(i)+0.5*k1*h, lc(i)+0.5*k1*h, z(i)+0.5*k1*h);
k3=h*f(t(i)+0.5*h, v(i)+0.5*k2*h, lc(i)+0.5*k2*h, z(i)+0.5*k2*h);
k4=h*f(t(i)+h, v(i)+k3*h, lc(i)+k3*h, z(i)+k3*h);
v(i+1)=v(i)+h/6*(k1+2*k2+2*k3+k4);
end
% 1 eq, 4variables
%im matlab Beginner, this is my code. who can i help me....
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!