mirror of
https://github.com/BreizhHardware/cours-ISEN-MD.git
synced 2026-03-18 21:50:46 +01:00
Obisidian vault auto-backup: 05-01-2026 14:58:35 on . 2 files edited
This commit is contained in:
@@ -1,41 +1,52 @@
|
|||||||
%% Experiment 7 : Spectral Analysis of the raised cosine waveform
|
%% Experiment 7 : Spectral Analysis of the raised cosine waveform
|
||||||
|
% Raised cosine pulse:
|
||||||
|
% h(t) = sinc(t/T) * cos(pi*beta*t/T) / (1 - (4*beta^2*t.^2)/T^2)
|
||||||
|
% where sinc(x) = sin(pi*x)/(pi*x).
|
||||||
|
%
|
||||||
|
% For this experiment:
|
||||||
|
% T = 2 ms
|
||||||
|
% beta = 0.5 (then 0.25)
|
||||||
|
% t in [-10T, 10T]
|
||||||
|
% Ts = 0.13*T (sampling period)
|
||||||
|
%
|
||||||
|
% We generate the pulse h(t), plot it in time (ms) and frequency (Hz),
|
||||||
|
% and compute the theoretical bandwidth B = (1/(2T))*(1+beta). [web:222][web:228]
|
||||||
|
|
||||||
clc;
|
clc;
|
||||||
clear;
|
clear;
|
||||||
close all;
|
close all;
|
||||||
|
|
||||||
%% Common parameters
|
%% 1) Common parameters
|
||||||
|
|
||||||
T = 2e-3; % Symbol period (s)
|
T = 2e-3; % Symbol period (s)
|
||||||
Ts = 0.13 * T; % Sampling period (s)
|
Ts = 0.13 * T; % Sampling period (s)
|
||||||
Fs = 1 / Ts; % Sampling frequency (Hz)
|
Fs = 1 / Ts; % Sampling frequency (Hz)
|
||||||
t = -10*T : Ts : 10*T; % Time vector from -10T to 10T
|
t = -10*T : Ts : 10*T; % Time vector from -10T to 10T
|
||||||
N = length(t); % Number of samples
|
N = length(t); % Number of samples
|
||||||
|
|
||||||
%% Helper function: raised cosine pulse (inline)
|
% Frequency axis for FFT (centered around 0)
|
||||||
% We handle the singularities at t = 0 and t = ±T/(2*beta) using limits.
|
f_axis = (-N/2 : N/2-1) * (Fs / N); % Hz
|
||||||
rc_pulse = @(beta) ...
|
|
||||||
arrayfun(@(tt) ...
|
% Inline handle to generate the pulse for any beta value
|
||||||
raisedCosineSample(tt, T, beta), t);
|
rc_pulse = @(beta) arrayfun(@(tt) raisedCosineSample(tt, T, beta), t);
|
||||||
|
|
||||||
|
%% ===================== beta = 0.5 =====================
|
||||||
|
|
||||||
%% ===== a) & b) for beta = 0.5 =====
|
|
||||||
beta1 = 0.5;
|
beta1 = 0.5;
|
||||||
|
|
||||||
h1 = rc_pulse(beta1); % Time-domain raised cosine pulse
|
% Time-domain pulse
|
||||||
|
h1 = rc_pulse(beta1);
|
||||||
|
|
||||||
% --- Time-domain plot (x-axis in ms) ---
|
|
||||||
figure('Name','Experiment 7 - Time domain, beta = 0.5');
|
figure('Name','Experiment 7 - Time domain, beta = 0.5');
|
||||||
plot(t*1e3, h1, 'g'); % t in ms
|
plot(t*1e3, h1, 'g'); % t in ms
|
||||||
xlabel('Time (ms)');
|
xlabel('Time (ms)');
|
||||||
ylabel('h(t)');
|
ylabel('h(t)');
|
||||||
title('Raised cosine pulse h(t), \beta = 0.5');
|
title('Raised cosine pulse h(t), \beta = 0.5');
|
||||||
grid on;
|
grid on;
|
||||||
|
|
||||||
% --- Frequency-domain magnitude spectrum ---
|
% Frequency-domain magnitude spectrum
|
||||||
H1 = fft(h1); % FFT of the pulse
|
H1 = fft(h1); % FFT of the pulse [web:8]
|
||||||
magH1 = abs(fftshift(H1)); % Center zero frequency; take magnitude
|
magH1 = abs(fftshift(H1)); % Magnitude, zero frequency centered [web:202]
|
||||||
|
|
||||||
% Frequency axis in Hz, centered around 0
|
|
||||||
f_axis = (-N/2:N/2-1) * (Fs/N);
|
|
||||||
|
|
||||||
figure('Name','Experiment 7 - Frequency domain, beta = 0.5');
|
figure('Name','Experiment 7 - Frequency domain, beta = 0.5');
|
||||||
plot(f_axis, magH1, 'g');
|
plot(f_axis, magH1, 'g');
|
||||||
@@ -44,19 +55,18 @@ ylabel('|H(f)|');
|
|||||||
title('Magnitude spectrum of raised cosine pulse, \beta = 0.5');
|
title('Magnitude spectrum of raised cosine pulse, \beta = 0.5');
|
||||||
grid on;
|
grid on;
|
||||||
|
|
||||||
% --- c) Measure bandwidth (approximate)
|
% Theoretical bandwidth
|
||||||
% For a raised cosine with symbol rate Rs = 1/T, ideal theoretical
|
Rs = 1 / T; % Symbol rate (Hz)
|
||||||
% baseband bandwidth is B = (Rs/2)*(1+beta).
|
BW_theo1 = (Rs/2) * (1 + beta1); % B = (Rs/2)*(1+beta) [web:222][web:228]
|
||||||
Rs = 1/T; % Symbol rate (Hz)
|
fprintf('Theoretical bandwidth for beta = 0.5 : %.2f Hz\n', BW_theo1);
|
||||||
BW_theo1 = (Rs/2) * (1 + beta1); % Theoretical bandwidth (Hz)
|
|
||||||
fprintf('Theoretical bandwidth for beta=0.5: %.2f Hz\n', BW_theo1);
|
%% ===================== beta = 0.25 =====================
|
||||||
|
|
||||||
%% ===== d) Repeat for beta = 0.25 =====
|
|
||||||
beta2 = 0.25;
|
beta2 = 0.25;
|
||||||
|
|
||||||
|
% Time-domain pulse
|
||||||
h2 = rc_pulse(beta2);
|
h2 = rc_pulse(beta2);
|
||||||
|
|
||||||
% Time-domain plot
|
|
||||||
figure('Name','Experiment 7 - Time domain, beta = 0.25');
|
figure('Name','Experiment 7 - Time domain, beta = 0.25');
|
||||||
plot(t*1e3, h2, 'g');
|
plot(t*1e3, h2, 'g');
|
||||||
xlabel('Time (ms)');
|
xlabel('Time (ms)');
|
||||||
@@ -65,8 +75,9 @@ title('Raised cosine pulse h(t), \beta = 0.25');
|
|||||||
grid on;
|
grid on;
|
||||||
|
|
||||||
% Frequency-domain magnitude spectrum
|
% Frequency-domain magnitude spectrum
|
||||||
H2 = fft(h2);
|
H2 = fft(h2);
|
||||||
magH2 = abs(fftshift(H2));
|
magH2 = abs(fftshift(H2));
|
||||||
|
|
||||||
figure('Name','Experiment 7 - Frequency domain, beta = 0.25');
|
figure('Name','Experiment 7 - Frequency domain, beta = 0.25');
|
||||||
plot(f_axis, magH2, 'g');
|
plot(f_axis, magH2, 'g');
|
||||||
xlabel('Frequency (Hz)');
|
xlabel('Frequency (Hz)');
|
||||||
@@ -74,23 +85,34 @@ ylabel('|H(f)|');
|
|||||||
title('Magnitude spectrum of raised cosine pulse, \beta = 0.25');
|
title('Magnitude spectrum of raised cosine pulse, \beta = 0.25');
|
||||||
grid on;
|
grid on;
|
||||||
|
|
||||||
|
% Theoretical bandwidth
|
||||||
BW_theo2 = (Rs/2) * (1 + beta2);
|
BW_theo2 = (Rs/2) * (1 + beta2);
|
||||||
fprintf('Theoretical bandwidth for beta=0.25: %.2f Hz\n', BW_theo2);
|
fprintf('Theoretical bandwidth for beta = 0.25 : %.2f Hz\n', BW_theo2);
|
||||||
|
|
||||||
%% ===== Local function for one sample of raised cosine =====
|
%% ===== Local function for one sample of raised cosine =====
|
||||||
function h = raisedCosineSample(t, T, beta)
|
function h = raisedCosineSample(t, T, beta)
|
||||||
% Raised cosine pulse sample at time t (scalar).
|
% Raised cosine pulse sample at time t (scalar).
|
||||||
% h(t) = sinc(t/T) * cos(pi*beta*t/T) / (1 - (4*beta^2*t^2)/T^2)
|
% h(t) = sinc(t/T) * cos(pi*beta*t/T) / (1 - (4*beta^2*t^2)/T^2)
|
||||||
% Special cases at t = 0 and t = ±T/(2*beta) use L'Hospital limits.
|
% with sinc(x) = sin(pi*x)/(pi*x).
|
||||||
|
% Special cases at t = 0 and t = ±T/(2*beta) use limit values. [web:223]
|
||||||
|
|
||||||
|
x = t / T;
|
||||||
|
|
||||||
|
% Manual definition of sinc(x) = sin(pi*x)/(pi*x)
|
||||||
|
if abs(x) < 1e-12
|
||||||
|
sx = 1; % limit at x -> 0
|
||||||
|
else
|
||||||
|
sx = sin(pi*x) / (pi*x);
|
||||||
|
end
|
||||||
|
|
||||||
|
% Handle critical points of the raised cosine denominator
|
||||||
if abs(t) < 1e-12
|
if abs(t) < 1e-12
|
||||||
% Limit at t -> 0
|
% At t -> 0, h(0) = 1 (sinc(0)=1 and cos(0)/(1-0)=1)
|
||||||
h = 1; % sinc(0) = 1 and cos(0)/(1-0) = 1
|
h = 1;
|
||||||
elseif beta ~= 0 && abs(abs(t) - T/(2*beta)) < 1e-12
|
elseif beta ~= 0 && abs(abs(t) - T/(2*beta)) < 1e-12
|
||||||
% Singularities at t = ±T/(2*beta) -> use known limit value
|
% Limit at t = ±T/(2*beta) [web:223]
|
||||||
h = (beta/pi) * sin(pi/(2*beta));
|
h = (beta/pi) * sin(pi/(2*beta));
|
||||||
else
|
else
|
||||||
x = t / T;
|
h = sx * cos(pi*beta*x) / (1 - (4*beta^2*x^2));
|
||||||
h = sinc(x) * cos(pi*beta*x) / (1 - (4*beta^2*x^2));
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user