# AERO3220 HW4 Program Flow Block Diagram ```mermaid flowchart TD A([Start Script]) --> B[Clear Workspace: clear, close all, clc] B --> C[Set Parameters: k1, k2, m1, m2] C --> D[Set Time Grid: t0, tf, dt, tspan] D --> E[Set Initial State Vector x0 with 4 states] E --> F[Define Input Force Functions: F1, F2, F3] F --> G[Case 1: b=100, F=F1] G --> H[Run ode45 with eom_two_mass] H --> I[Case 2: b=100, F=F2] I --> J[Run ode45 with eom_two_mass] J --> K[Case 3: b=0, F=F2] K --> L[Run ode45 with eom_two_mass] L --> M[Case 4: b=100, F=F3] M --> N[Run ode45 with eom_two_mass] N --> O[Case 5: b=0, F=F3] O --> P[Run ode45 with eom_two_mass] P --> Q[Build Legend Strings] Q --> R[Plot Figure 1: z1 vs time for 5 cases] R --> S[Plot Figure 2: z2 vs time for 5 cases] S --> T[Plot Figure 3: z1dot vs time for 5 cases] T --> U[Plot Figure 4: z2dot vs time for 5 cases] U --> V[Plot Figure 5: z1 and z2 together by case] V --> W[Local Function eom_two_mass] W --> X[Unpack States: z1, z1dot, z2, z2dot] X --> Y[Evaluate Input u = Ffun of t] Y --> Z[Compute Accelerations: z1ddot and z2ddot] Z --> AA[Return State Derivative Vector dx with 4 elements] AA --> AB([End]) ``` ## ODE Model Used in Each Case \[ \ddot{z}_1 = -\frac{k_1}{m_1}z_1 + \frac{k_1}{m_1}z_2 \] \[ \ddot{z}_2 = \frac{k_1}{m_2}z_1 - \frac{k_1+k_2}{m_2}z_2 - \frac{b}{m_2}\dot{z}_2 + \frac{1}{m_2}u(t) \] where \(u(t)\) is one of the three forcing functions depending on the case. ## Assignment-Style Block Diagram (Recommended For Submission) ```mermaid flowchart TD A([Start]) --> B[Define constants and masses: k1, k2, m1, m2] B --> C[Define simulation time: t0, tf, dt, tspan] C --> D[Set initial state vector x0 with 4 states] D --> E[Define force inputs F1 constant, F2 sine slow, F3 sine fast] E --> F[Create case table with case b and force] F --> G{i <= Number of Cases?} G -- Yes --> H[Load case i values: b_i, F_i] H --> I[Call ode45 with eom_two_mass and current case] I --> J[Store outputs: t_i and x_i] J --> K[i = i + 1] K --> G G -- No --> L[Generate legend labels] L --> M[Plot z1 vs time for all cases] M --> N[Plot z2 vs time for all cases] N --> O[Plot z1dot vs time for all cases] O --> P[Plot z2dot vs time for all cases] P --> Q[Plot combined z1 and z2 by case] Q --> R([End]) ``` ### Solver Subsystem (Inside `eom_two_mass`) ```mermaid flowchart LR A1[Inputs: t, x, m1, m2, k1, k2, b, Ffun] --> A2[Unpack states: z1, z1dot, z2, z2dot] A2 --> A3[Compute input force u from Ffun and t] A3 --> A4[Compute z1ddot from mass 1 equation] A4 --> A5[Compute z2ddot from mass 2 equation] A5 --> A6[Assemble derivative vector dx with 4 elements] A6 --> A7[Return dx to ode45] ```