A simple MATLAB script to check if two signals are orthogonal over a specified interval by calculating the integral of their product.
- Open the Script: Open the
.mfile in MATLAB. - Modify Inputs: Locate the
--- INPUT SECTION ---and change these variables:f1_str: First function as a string (e.g.,'sin(t)').f2_str: Second function as a string (e.g.,'cos(t)').interval_start/interval_end: Integration limits.step_size: Resolution for numerical integration (smaller = more accurate).
- Run: Press Run (F5).
- Built-in:
sin(t),cos(t),exp(t), etc. - Predefined:
u_step(t)→ Unit step functionramp(t)→ Ramp function
- Command Window: Displays whether the signals are ORTHOGONAL or NOT ORTHOGONAL and prints the calculated integral value.
- Figure: Plots both input signals and their product.
f1_str = 'sin(t)';
f2_str = 'cos(t)';
interval_start = -pi;
interval_end = pi;Result: ORTHOGONAL