# Demo — Phased Array Simulator

This is the interactive phased-array simulator we use in class, embedded here for self-study. It builds the array factor for a linear or planar array, steers the beam with element phasing, and visualizes the result five ways: a pattern plot, a 2D heatmap, the element phase fronts, a polar cut, and a 3D hemisphere. Use it to *see* the ideas from the reading — beam steering, beamwidth, side lobes, and grating lobes.

## The idea

Each element radiates the same signal with a programmed phase. Sloping the phase across the array tilts the wavefront and points the main lobe at the steering angle $\theta_0$:

$$
\Delta\phi = \frac{2\pi}{\lambda}\,d\,\sin\theta_0.
$$

Keep the spacing $d \le \lambda/2$ to avoid grating lobes at broadside.

## Interactive demo

<a class="demo-fullscreen" href="../_static/demos/array-demo/index.html" target="_blank" rel="noopener">Open in full screen</a>

<div class="demo-wrap">
<iframe src="../_static/demos/array-demo/index.html"
        title="Interactive phased-array simulator"
        width="100%"
        style="min-height:700px;height:700px;"
        loading="lazy">
</iframe>
</div>

## Walkthrough

Work the **Pattern** tab first, then **Polar Cut**, then **Planar**, then **3D Hemisphere**.

1. **Baseline.** Linear, $M = 8$, $d_x/\lambda = 0.50$, $\theta_0 = 0$. Note the main lobe at boresight and the first side lobes near $-13$ dB (uniform illumination).
2. **Steer it.** Push $\theta_0$ to $30^\circ$, then $60^\circ$. The main lobe moves to the steering angle and **broadens** by about $1/\cos\theta_0$.
3. **Read the numbers.** Switch to **Polar Cut** and read HPBW and SLL directly. At $N = 8$, $d = \lambda/2$, boresight, HPBW is about $12.7^\circ$ — the in-class MATLAB anchor.
4. **Break it.** Raise $d_x/\lambda$ from $0.50$ to $0.80$. **Grating lobes** appear. EW implication: a poorly spaced array leaks full-strength energy in unintended directions.
5. **Go planar.** Switch to **Planar** ($M = 8$, $N = 8$, $d_x = d_y = \lambda/2$) and steer $\theta_0$ and $\phi_0$. The **2D Heatmap** shows the beam wandering across the hemisphere.
6. **See the cone.** Open the **3D Hemisphere** tab. Drag to rotate and confirm the focused cone with its surrounding side-lobe rings.
7. **Add the element factor.** Toggle **Element factor (cos θ)**. The distant side lobes pull back toward boresight — real elements have their own pattern that multiplies the array factor.

## Key observations

- **Uniform illumination → ≈ −13 dB side lobes.** Tapering would lower them at the cost of a wider main beam.
- **HPBW broadens as $1/\cos\theta_0$.** Steering to $60^\circ$ roughly doubles the beamwidth and costs about 3 dB of gain.
- **Grating lobes appear for $d > \lambda/2$ at broadside** — the angular-domain Nyquist limit.
- **A planar array's beam is a 3D cone**, steerable in both azimuth and elevation.

## Source

<a class="matlab-link" href="../_static/downloads/ECE%20495%20EW%20%E2%80%93%20Code.zip#code/L6_ArrayFactorAndSteering.m" download><svg viewBox="0 0 22 22" width="14" height="14" aria-hidden="true" style="vertical-align:-2px;margin-right:6px;"><rect width="22" height="22" rx="3" fill="#e87722"/><text x="11" y="15.5" text-anchor="middle" font-family="'Inter',sans-serif" font-size="9" font-weight="800" fill="#fff" letter-spacing="-0.04em">MAT</text></svg><span class="ml-text">MATLAB · code/L6_ArrayFactorAndSteering.m</span><span class="ml-arrow">↓</span></a>

The in-class script builds the array factor for an $N$-element linear array, plots it in polar dB, steers the beam to $0^\circ$, $30^\circ$, and $60^\circ$ to watch the HPBW broaden, and marks the first side-lobe level to confirm the $-13.2$ dB rule.
