Trying to solve 4 coupled differential equations using ode45 and keep getting the error not enough input arguments
Ältere Kommentare anzeigen
function Q2a
m0 = 120000;
n = 15;
mf = m0/n;
Isp = 320;
g = 9.81;
T = 1.4*m0*g;
me = T/(Isp*g);
t0 = 0;
tb = (m0 - mf)/me;
tspan = [t0 tb];
gamma0 = 1.568;
m = [m0 mf];
ht = 110;
function dvdt = velocity(t,g,T,m,gamma0,ht,littlegam)
while alt <= ht
dvdt = (T - m*g*sin(gamma0))/m ;
end
while alt > ht
dvdt = (T - m*g*sin(littlegam))/m;
end
end
function [t,v] = vel(tspan,g,T,m,gamma0,ht,littlegam,t)
v0 = 0;
[t,v] = ode45(@(t,m) velocity(t,g,T,m,gamma0,ht,littlegam) ,tspan , v0);
output(t,v)
end
function dhdt = altitude(t,vel,littlegam,ht,gamma0)
v = vel;
while ht >= alt
dhdt=v.*sin(gamma0);
end
while alt > ht
dhdt = v.*sin(littlegam);
end
end
function [t,h] = alt(tspan, vel, littlegam, ht, gamma0)
h0 = 0;
[t,h] = ode45(@(t,vel) altitude(t,vel,littlegam,ht,gamma0) , tspan, h0);
end
function dgammadt = pitch_angle(t,g0,littlegam,vel,Re,alt,gamma0,ht)
h = alt;
v = vel;
while ht >= alt
dgammadt=(-(1./v)).*(g0-((v.^2)./(Re+h))).*(cos(gamma0));
end
while alt > ht
dgammadt=(-(1./v)).*(g0-((v.^2)./(Re+h))).*(cos(littlegam));
end
end
function [t,gamma] = littlegam(g0,alt,Re,vel,gamma0,tspan,ht)
[t,gamma] = ode45(@(t,vel) pitch_angle(t,g0,littlegam, vel, Re, alt, gamma0, ht) , tspan, gamma0);
end
function dxdt = downrange_dist(Re,alt,vel,littlegam,ht,gamma0,t)
while ht >= alt
dxdt=(Re./(Re+ h)).*v.*cos(gamma0);
end
while alt > ht
dxdt=(Re./(Re+ alt)).*vel.*cos(littlegam);
end
end
function [t,x] = dis(Re,alt,vel,littlegam,tspan,ht,gamma0)
x0 = 0;
[t,x] = ode45(@(t,alt) downrange_dist(Re,alt,vel,littlegam,ht,gamma0,t), tspan, x0);
end
plot(tspan,vel);
plot(tspan,alt);
plot(tspan,littlegam);
plot(tspan,dis);
end
1 Kommentar
Sonny Whittley
am 26 Mär. 2018
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Ordinary Differential Equations 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!