run_allThis builds the aero/thrust tables, builds and validates the open-loop model, then designs, builds, and validates the augmented (SAS) model end to end.
make_tables % build data/*.mat + verification figures
quicktest % sanity check + open-loop figure
build_openloop_model % build f16_openloop.slx
sim('f16_openloop')
outOL = validate_openloop; % trim+modes, then native .slx vs plant_ode.m
outAug = validate_augmented; % designs SAS gains, saves data/sas_gains.mat
build_augmented_model % build f16_augmented.slx WITH those gains
outAug = validate_augmented; % re-run: now also checks the built model
sim('f16_augmented')The augmented model has to be built after validate_augmented has
saved gains at least once, that's why it's called twice above. If you
run build_augmented_model before any gains exist, it falls back to
conservative defaults. Re-run validate_augmented and rebuild.
After editing params.m or regenerating tables, run clear all first so
cached persistent values reload.
export_sil_reference % open-loop plant, any time
export_sas_sil_reference % closed-loop SAS trajectory, needs data/ sas_gains.mat, so run validate_augmented firstBoth write CSVs into ../cpp/tests/ for the C++ side to read.
benchmark_timing % needs f16_openloop.slx built first;
% uses data/augmented_results.mat if present for a sharper step-size justificationPrints the step-size justification (derived from the fastest achieved
closed-loop bandwidth), then times the raw .m chain and the compiled
Simulink model, reporting mean/median/P95/P99/max/jitter and the
sustained real-time rate. Writes ../cpp/tests/matlab_timing_reference.csv
for the C++ benchmark to read.
mingw32-make
This builds five executables in bin/: run_openloop, run_augmented,
sil_test, sas_sil_test, benchmark.
./bin/run_openloop
Integrates the open-loop plant from trim for 20s. Prints the final state
(should barely have moved) and saves openloop_trajectory.csv.
./bin/run_augmented
Runs the aft-c.g. instability demo open-loop vs. closed-loop (SAS
engaged) response to the same perturbation. Prints growing/damped
verdicts and saves augmented_openloop.csv / augmented_closedloop.csv
-- plot q_dps vs t from both on the same chart (Excel, Python/pandas,
or MATLAB's readtable+plot all work) to see the divergent-vs-damped
curves directly.
./bin/sil_test
Always runs an internal trim/residual self-check. If
tests/sil_reference.csv exists (from export_sil_reference in
MATLAB), it also runs a genuine cross-language comparison against that
reference and prints per-state differences.
./bin/sas_sil_test
Needs tests/sas_sil_reference.csv (from export_sas_sil_reference in
MATLAB) to do anything -- without it, it just prints what to run and
exits cleanly. With it, replays MATLAB's exact closed-loop trajectory
step by step and compares.
No rebuild needed after regenerating either CSV, re-run the executable.
./bin/benchmark
Times the open-loop plant and the closed-loop (SAS-engaged) case,
reporting mean/median/P95/P99/max/jitter and the sustained real-time
rate for each. If tests/matlab_timing_reference.csv exists (from
benchmark_timing in MATLAB), also prints the C++-vs-MATLAB speedup
factor against both the raw .m chain and the compiled Simulink model
baselines.
make clean
Removes bin/ and any .csv output files.