How can I fix this program with ODE45?

Code:
clc, close all;
hours = 3600;
days = 24*hours;
deg = pi/180;
mu = 398600;
RE = 6378;
wE = [ 0 0 7.2921159e-5]';
CD = 2.2;
m = 100;
A = pi/4*(1^2);
rp = RE + 215;
ra = RE + 939;
RA = 339.94*deg;
i = 65.1*deg;
w = 58*deg;
TA = 332*deg;
e = (ra-rp)/(ra+rp);
a = (rp + ra)/2;
h = sqrt(mu*a*(1-e^2));
T = 2*pi/sqrt(mu)*a^1.5;
coe0 = [h e RA i w TA];
[R0, V0] = sv_from_coe(coe0, mu);
r0 = norm(R0);
v0 = norm(V0);
t0 = 0;
tf = 120*days;
y0 = [R0 V0]';
nout = 40000;
tspan = linspace(t0, tf, nout);
% Set error tolerances, initial step size, and termination event:
options = odeset(’reltol’, 1.e-8, ...
’abstol’, 1.e-8, ...
’initialstep’, T/10000, ...
’events’, @terminate);
global alt %Altitude
[t,y] = ode45(@rates, tspan, y0,options); %t is the solution times
Result:
Please, help me to answer my last project with this method. I'm still confusing about this problem. Anything idea?

回答(1 个)

You are using the wrong character (’) in your code. MATLAB does not recognize it to create strings. Use the apostrophe symbol (') instead. For example, copy and paste the lines in your code and delete the older lines
options = odeset('reltol', 1.e-8, ...
'abstol', 1.e-8, ...
'initialstep', T/10000, ...
'events', @terminate);

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

产品

版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by