How do you set up a function file to loop through a vector of values for use with ode45?
1 view (last 30 days)
Show older comments
From input file (the length of CL is known--26):
i = 1:length(CL);
in.C_L = CL(i);
in.C_D = CD(i);
From EOM Function file:
C_L = in.C_L;
C_D = in.C_D;
i = 1; % this runs case 1 only
B = mass./(C_D(i)*area); % ballistic coefficient
rho = rho_0*exp(-h/H); % exponential atmosphere
r = R + h; % radius of planet plus height
L = 0.5*rho*V^2.*C_L(i)*area; % lift
D = 0.5*rho*V^2.*C_D(i)*area; % drag
L_D = L/D; % lift-to-drag coefficient
% Planar equations of motion
Vdot = -(rho*V^2)./(2*B) - g*sin(gamma);
gammadot = (((V^2*cos(gamma))/r + ((rho.*V^2)./(2*B)).*(L_D) - g*cos(gamma))/V);
hdot = V.*sin(gamma);
EOM = [Vdot; gammadot; hdot];
Calling ode45 from main file with constant values for y0:
[t,y] = ode45(@HW7_P4_EOM, [0:96], y0, options);
I can extract all the information needed for C_L and C_D. But I'm having trouble running each case of the 26-element vector through ode45 and saving the results from each case for plotting. I was thinking of running a for loop with the ode45 command, and using hold all for plotting, but I don't know how to vary loop through ode45 using the different parameters.
Thanks!
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!