Aim
Write a program to generate discrete sequences: (i) unit step, (ii) unit impulse, (iii) ramp and (iv) periodic sinusoid, and plot them all. Use a function generator and CRO to observe these signals in continuous time, and vary and measure their amplitude and frequency. Generate the same signals with the Simulink toolbox.
Objectives
- Define δ[n], u[n], r[n] and A·cos(ω₀n+φ) and generate each one with vector operations.
- Find out when a discrete sinusoid is periodic, and work out its fundamental period N.
- Use the CRO graticule (V/div, time/div) to measure peak-to-peak voltage, period and frequency.
- Make the same signals with Simulink Source blocks and view them on a multi-channel Scope.
Apparatus
| Real lab | Virtual equivalent |
|---|---|
| MATLAB + Simulink | Sequence generator + Simulink block view |
| Function generator (0.1 Hz – 1 MHz) | Virtual function generator with sine, square, triangle and ramp |
| Dual-trace CRO (20 MHz) | Virtual CRO with V/div, time/div and trigger |
| BNC probes and leads | (wired for you) |
Elementary discrete-time signals
These signals are related: δ[n] = u[n] − u[n−1], u[n] = Σ δ[k] for k ≤ n, and r[n] = n·u[n]. Any discrete signal can be written as a weighted sum of shifted impulses: x[n] = Σ x[k]·δ[n−k].
Periodicity of a discrete sinusoid
x[n] = cos(2πf₀n) is periodic only if f₀ = k/N is a rational number. The fundamental period is the smallest N for which f₀N is a whole number. For example, f₀ = 3/20 gives N = 20. But cos(0.5n) has ω₀ = 0.5, so f₀ = 0.5/2π is irrational and the sequence never repeats exactly.
Measuring with a CRO
A. MATLAB sequences
- Choose a signal type in Simulator → A.
- Set the range n = N₁…N₂ and the amplitude.
- Shift with n₀ and see the formula change.
- For the sinusoid, try f₀ = 0.05, 0.15 and 0.5/2π, and note whether each one is periodic.
- Switch on Show all four to see the signals side by side.
B. Function generator & CRO
- Choose sine and set 1 kHz and 4 Vpp.
- Adjust V/div and time/div until about 2 cycles fill the screen.
- Count the vertical divisions peak to peak and the horizontal divisions per cycle.
- Work out Vpp and f, and type them into the Observations table.
- Repeat for square, triangle and ramp waves at 3 different settings.
- Move the trigger level outside the signal and watch the trace roll.
C. Simulink
- Turn on the Step, Pulse (impulse), Ramp and Sine blocks.
- Set their parameters and press Run.
- Compare the 4-channel scope with the MATLAB plots.
Pre-lab diagnostic
A. Discrete sequence generator
Parameters
B. Function generator → CRO
Function generator
The speaker follows the waveform, frequency and amplitude live. Square and ramp sound "buzzier" because they contain more harmonics.
CRO controls
C. Simulink — 4-channel scope
Source blocks
Table 1 — Amplitude measurement on the CRO
Record a setting, read the graticule, then type your measured Vpp.
Table 2 — Frequency measurement on the CRO
Table 3 — Periodicity of discrete sinusoids
Analysis
Post-lab quiz
Self-evaluation
exp2_signals.m
%% Experiment 2: Elementary discrete-time signals clc; clear; close all; n = -10:10; imp = (n==0); % unit impulse stp = (n>=0); % unit step rmp = n.*(n>=0); % unit ramp A = 2; f0 = 0.1; phi = 0; sn = A*cos(2*pi*f0*n + phi); % sinusoid, N = 1/f0 = 10 subplot(2,2,1); stem(n,imp,'filled'); title('\delta[n]'); subplot(2,2,2); stem(n,stp,'filled'); title('u[n]'); subplot(2,2,3); stem(n,rmp,'filled'); title('r[n]'); subplot(2,2,4); stem(n,sn ,'filled'); title('A cos(2\pi f_0 n)'); for k=1:4, subplot(2,2,k); xlabel('n'); grid on; end %% Simulink: Step, Pulse Generator (width=1 sample), Ramp, Sine Wave -> Mux -> Scope