I need help constructing a more efficient code to plot multiple data points on one step plot
15 views (last 30 days)
Show older comments
I am working on an assignment for my Stability and Control class that is pretty extensive as far as lines of code are concerned. We are to code flight dynamics for a Cessna 182 aircraft in which we are analyzing the flight affects of things such as:
- AoA/Pitch due to elevator deflection
- Slide slip due to aileron/rudder deflection
- Heading due to aileron/rudder deflection
We are analyzing the short period, phugoid, dutch roll, roll, short period approximation, phugoid approximation, Dutch roll approximation, and roll approximations transfer functions for the aircraft in 3 different flight conditions; Climb, Cruise, and Approach. We are given the aircrafts specific data, longitudinal, and lateral-directional variables.
I have already created the code for each aformentioned condition but they are in separate .m files. What I would ultimately like to happen is have a single file or a couple of files (longitudinal and lateral-directional) that can model these dynamics and output a step(sys) plot that overlays the first 3 seconds of the dynamics (t = 0:0.01:3) for each analysis with its associated approximation e.g. AoA to elevator deflection for climb, cruise, and approach short period dynamics and short period approximation for climb, cruise, and approach -- 6 trends on one plot.
I am adding the code for just the AoA to elevator deflection and approximation for all three flight conditions to this query to see if someone is able to find a solution that is more efficient than having separate files. I am not MATLAB savvy enough to create a more truncated solution yet.
4 Comments
Paul
on 22 Nov 2022
Edited: Paul
on 22 Nov 2022
If using a model array, each model is stored as one element of the array. The model array itself can be multi-dimensional if it makes sense to do so. Here's a simple example.
sys1 = tf(1,[1 1],'Name','pitch');
sys2 = tf(1,[2 1],'Name','yaw');
sys = stack(1,sys1,sys2);
step(sys),legend
Actually, now that I think of it one of the drawbacks of Model Arrays is shown above, i.e., it's not easy to distinguish which curve on the plot goes with which model. Maybe it's easier to do
step(sys1,sys2),legend
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!