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.