I have problem of ode45. please help me T_T
1 次查看(过去 30 天)
显示 更早的评论
(sorry about my english skill)
first, this is rocket.m file
function dH=rocket(t,H)
global km mildo press temp;
m = 6100; % kg
a = 0.8; % m^2
ve = 2060.1; % m/s
thrust = 13000*9.81;
pe = thrust/a;
dmdt = -(thrust)/ve;
rho = 1;
pa = 1;
tem = 1;
%M = (331.5+(0.6*tem));
veeff = ve-a*(pe-pa)/dmdt; % ve.eff
%v = ;
cd = 1;
dH(1,1) = H(2);
dH(2,1) = cd*rho(1)*a*H(1)^2-dmdt*ve;
and this is rocket_test.m file
[t H] = ode45(@(t,H)rocket(t,H),[0 10],[0 0]);
H1=H(:,1);
H2=H(:,2);
plot(t,H1,t,H2)
legend('height','vel')
set(gca,'fontsize',20)
when i run rocket_test.m code, the error massage is
Warning: Failure at t=1.930812e-01. Unable to meet integration tolerances without
reducing the step size below the smallest value allowed (4.440892e-16) at time t.
> In ode45 (line 308)
In rocket_test (line 2)
and when i change dH(2,1)=cd*rho(1)*a*H(1)^2-dmdt*ve; to dH(2,1)=cd*rho(1)*a*H(1)-dmdt*ve; at rocket.m file, it works.
so i think H(1) ^2 the square is the problem.
but when i test below code, it works. function dH=rocket(t,H) dH(1,1) = H(2); dH(2,1) = H(1)^2;
i can't find what is the problems..........
+ someone said try ode15s instead ode45, but ode15s didn't work neither
0 个评论
回答(1 个)
Jan Orwat
2016-6-11
编辑:Jan Orwat
2016-6-11
1. It seems your function rocket.m represents system of equations
dH₁ = H₂
dH₂ = aH₁² + 127530
Verify, if it's what you are looking for.
2. Why do you declare global variables? Are those necessary? They aren't used once. MATLAB allows use of global variables, but it is not recommended. In this case
3. I cleaned up rocked.m from all unused or redundant variables. Here's what is left:
function dH=rocket(~,H)
a = 0.8; % m^2
thrust = 13000*9.81;
dH(1,1) = H(2);
dH(2,1) = a*H(1)^2+thrust;
Make sure if it's correct. If it calculates what it's supposed to do, then go to point 3.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!