Filter löschen
Filter löschen

How to make a visible side bands in the waterfall of AM signal with Fc = 440 and Fs = 10?

2 Ansichten (letzte 30 Tage)
Hey,
I need to do a waterfall for an AM signal for 3 modulation indexes. The problem is that the carrier frequency should be 440Hz and the frequency of the source signal is 10Hz. I've tried a lot of parameters, but every time I print the waterfall I don't see the sidebands. My math is good, so the problem in the visibilty probably comes from the low frequency of the source signal (the side-bands should be around 430Hz and 440Hz). What can I do to actually see the side bands? to see the modulation!
This is my code:
close all; % close all : close all open figures
% whose 'HandleVisability' property set to 'on'
clear; % removes all variables from the current workspace,
% releasing them for system memory
clc; % clears all the text from the Command Window,
% resulting in a clear screen
% Values for the spectrogram
M = 1024;
L = 200;
window = bartlett(M);
ndft = 4096;
Fc = 440; % Frequency of the carrier wave [Hz]
Fs = 10; % Frequency of the modulated wave signal [Hz]
As = 1;
Ac = 1;
modulationFactors = [0.5, 1, 1.5]; % Modulation factors
sampleRate = 16000; % Samples per second
signalLengthInSeconds = 2;
time = linspace(0,signalLengthInSeconds,sampleRate*signalLengthInSeconds+1); % Time Vector +1 Sample
time(end)=[]; % Remove extra sample
x_carrier = Ac*sin(2*pi*Fc*time);
x_signal = As*sin(2*pi*Fs*time);
for i = 1:length(modulationFactors)
if (abs(modulationFactors(i)) > 1)
disp(append(string(modulationFactors(i)) ," is a bad modulation factor"));
end
% Generating AM Signal
amSignal = (Ac + (modulationFactors(i))*x_signal) .* x_carrier;
% Plotting synthetic digital sinus audio signal
figure;
subplot(5,1,1);
plot(time, x_signal)
title('Source signal of 10 Hz');
xlabel('Time in seconds');
ylabel('Amplitude');
subplot(5,1,2);
plot(time, x_carrier)
title('Carrier signal of 440 Hz');
xlabel('Time in seconds');
ylabel('Amplitude');
subplot(5,1,3);
plot(time, amSignal);
title(append("Amplitude modulation with a modulation factor of ", string(modulationFactors(i))));
xlabel('Time in seconds');
ylabel('Amplitude');
sound(x_signal, sampleRate);
pause(4);
sound(amSignal,sampleRate);
pause(4);
WAVfileName = sprintf('%s_%d%s', 'EX_02_01_2Audio', i, '.wav');
% WAV file will be created in the directory of the script
if exist(WAVfileName, 'file')==2
delete(WAVfileName);
end
% Normalize AM signal to range [-1, 1] before saving
AMsignalNormalized = amSignal / max(abs(amSignal));
audiowrite(WAVfileName, AMsignalNormalized, sampleRate);
% Creating spectrogram
figure;
spectrogram(amSignal, window, L, ndft, sampleRate, 'yaxis');
[s,f,t] = spectrogram(amSignal, window, L, ndft, sampleRate, 'yaxis');
title(['AM Signal with Modulation Factor = ', num2str(modulationFactors(i))]);
figure;
% Waterfall plot of spectrogram
waterfall(f,t,abs(s)'.^2)
set(gca,XDir="reverse",View=[30 50])
xlim([350 550]);
title(['AM Signal with Modulation Factor = ', num2str(modulationFactors(i))]);
xlabel("Frequency (Hz)");
ylabel("Time (s)");
zlabel('Power');
end
WAVfileName_original = 'OriginalAudio02_01_2.wav';
% WAV file will be created in the directory of the script
if exist(WAVfileName_original, 'file')==2
delete(WAVfileName_original);
end
audiowrite(WAVfileName_original, x_signal, sampleRate);
[s,f,t] = spectrogram(x_signal, window, L, ndft, sampleRate, 'yaxis');
figure; spectrogram(x_signal, window, L, ndft, sampleRate, 'yaxis');
title(['Original Signal']);
figure; waterfall(f,t,abs(s)'.^2)
set(gca,XDir="reverse",View=[30 50])
xlabel('Frequency [Hz]');
ylabel('Time (s)');
title(['Original Signal']);
I'll appreciate any help. Thanks.

Antworten (1)

Neelanshu
Neelanshu am 16 Apr. 2024
Hi Lior,
To make the sidebands visible in the waterfall display, you need a smaller frequency resolution, which is given by the equation:
where represents frequency resolution, represents the sampling frequency and represents the window size. According to the following paper, the minimum window size to distinguish two closely spaced components is given by :
Hence, in this case, with a sampling rate of 16KHz and closest frequency components being 10 Hz apart, you will require a window size of at least 3200 samples. Additionally, the sidebands will be around 430 Hz and 450 Hz, not 440 Hz and 430 Hz.
Here is the code and obtained output for window size of 4096 samples :
close all; % close all : close all open figures
% whose 'HandleVisability' property set to 'on'
clear; % removes all variables from the current workspace,
% releasing them for system memory
clc; % clears all the text from the Command Window,
% resulting in a clear screen
format long
% Values for the spectrogram
M = 1024*4; % for sideband display
L = 200;
window = bartlett(M);
ndft = 4096*4; %for smooth graph
Fc = 440; % Frequency of the carrier wave [Hz]
Fs = 10; % Frequency of the modulated wave signal [Hz]
As = 1;
Ac = 1;
modulationFactors = [0.5, 1, 1.5]; % Modulation factors
sampleRate = 16000; % Samples per second
signalLengthInSeconds = 2;
time = linspace(0,signalLengthInSeconds,sampleRate*signalLengthInSeconds+1); % Time Vector +1 Sample
time(end)=[]; % Remove extra sample
x_carrier = Ac*sin(2*pi*Fc*time);
x_signal = As*sin(2*pi*Fs*time);
for i = 1:length(modulationFactors)
if (abs(modulationFactors(i)) > 1)
disp(append(string(modulationFactors(i)) ," is a bad modulation factor"));
end
% Generating AM Signal
amSignal = (1 + (modulationFactors(i))*x_signal/As) .* x_carrier;
% Plotting synthetic digital sinus audio signal
figure;
subplot(5,1,1);
plot(time, x_signal)
title('Source signal of 10 Hz');
xlabel('Time in seconds');
ylabel('Amplitude');
subplot(5,1,2);
plot(time, x_carrier)
title('Carrier signal of 440 Hz');
xlabel('Time in seconds');
ylabel('Amplitude');
subplot(5,1,3);
plot(time, amSignal);
title(append("Amplitude modulation with a modulation factor of ", string(modulationFactors(i))));
xlabel('Time in seconds');
ylabel('Amplitude');
sound(x_signal, sampleRate);
pause(4);
sound(amSignal,sampleRate);
pause(4);
WAVfileName = sprintf('%s_%d%s', 'EX_02_01_2Audio', i, '.wav');
% WAV file will be created in the directory of the script
if exist(WAVfileName, 'file')==2
delete(WAVfileName);
end
% Normalize AM signal to range [-1, 1] before saving
AMsignalNormalized = amSignal / max(abs(amSignal));
audiowrite(WAVfileName, AMsignalNormalized, sampleRate);
% Creating spectrogram
figure;
spectrogram(amSignal, window, L, ndft, sampleRate, 'yaxis');
[s,f,t] = spectrogram(amSignal, window, L, ndft, sampleRate, 'yaxis');
title(['AM Signal with Modulation Factor = ', num2str(modulationFactors(i))]);
figure;
% Waterfall plot of spectrogram
waterfall(f,t,abs(s)'.^2)
set(gca,XDir="reverse",View=[30 50])
xlim([350 550]);
title(['AM Signal with Modulation Factor = ', num2str(modulationFactors(i))]);
xlabel("Frequency (Hz)");
ylabel("Time (s)");
zlabel('Power');
end
WAVfileName_original = 'OriginalAudio02_01_2.wav';
% WAV file will be created in the directory of the script
if exist(WAVfileName_original, 'file')==2
delete(WAVfileName_original);
end
audiowrite(WAVfileName_original, x_signal, sampleRate);
[s,f,t] = spectrogram(x_signal, window, L, ndft, sampleRate, 'yaxis');
figure; spectrogram(x_signal, window, L, ndft, sampleRate, 'yaxis');
title(['Original Signal']);
figure; waterfall(f,t,abs(s)'.^2)
set(gca,XDir="reverse",View=[30 50])
xlabel('Frequency [Hz]');
ylabel('Time (s)');
title(['Original Signal']);
Hope this helps.

Produkte


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by