To visualize how the elevator, aileron, and rudder deflections evolve over time during your simulation, you’ll need to extract or reconstruct these values at each time step and then plot them using MATLAB. Here's a high-level approach you can follow:
1. Integrate your dynamics using ode45
- Use the "ode45" solver to simulate your aircraft model over a time span.
- If control inputs are constant, define "de0", "da0", "dr0" before simulation and treat them as fixed throughout.
- If you plan to vary control inputs, you’ll need to modify your "STOL_EOM" to accept them as inputs (e.g., via interpolation tables or a controller function).
2. Record control inputs at each time step
- Since "de", "da", and "dr" are set as constants inside "STOL_EOM", you can reconstruct them after the simulation using their global values.
global de0 da0 dr0
de_array = de0 * ones(size(t));
da_array = da0 * ones(size(t));
dr_array = dr0 * ones(size(t));
3. Plot the control deflections
- Use "figure", "subplot", and "plot" to display each control signal over time:
figure
subplot(3,1,1)
plot(t, de_array)
ylabel('Elevator deflection \delta_e')
grid on
subplot(3,1,2)
plot(t, da_array)
ylabel('Aileron deflection \delta_a')
grid on
subplot(3,1,3)
plot(t, dr_array)
ylabel('Rudder deflection \delta_r')
xlabel('Time (s)')
grid on
Refer to the following documentation pages for more information:
- ode45 solver: https://www.mathworks.com/help/matlab/ref/ode45.html
- odeset options: https://www.mathworks.com/help/matlab/ref/odeset.html
- odeplot real-time plotting: https://www.mathworks.com/help/matlab/ref/odeplot.html
- Basic plotting (plot, figure): https://www.mathworks.com/help/matlab/ref/plot.html
- Subplots: https://www.mathworks.com/help/matlab/ref/subplot.html