Non constant Sampling Frequency in FFT of Amplitude Modulation

8 views (last 30 days)
Hello. I'm trying to code the double sideband and single side frequency spectrum of a amplitude modulated signal. Problem is I'm not sure how to set the sampling frequency, fs. I want to set fs in a way that it is proportional to the amplitude modulated signal, meaning fs changes in value according to the amplitude modulated signal. For my current coding of fs, a matrix error occur that I'm not sure how to fix. Is there any coding or equation that I could fit in my coding for fs? Thank you in advance for those who helps me.
Em=5;
Ec=5;
fm=100;
fc=1000;
Tm=1/fm;
y= Ec*cos(2*pi*fc*t)+(Em/2)*cos(2*pi*(fc+fm)*t) + (Em/2)*cos(2*pi*(fc-fm)*t); % Equation of Amplitude modulated signal
t=0:Tm/999:6*Tm; % Total time for modulated signal simulation (6 cycles will be displayed)
N = length(y); %Number of samples
fs= N/t; %sampling frequency
f =(0:N-1)*(fs/N); %frequency range(Hz)
%Double-sideband frequency spectrum
figure(1);
subplot(3,1,1);
yy = fftshift(fft(y));
Amp =(abs(yy/N)); %Amplitude of spectrum
plot(f(1:N),Amp(1:N)); %continuous frequency spectrum
xlabel('Frequency (Hz)')
ylabel('Amplitude');
title('Double-sideband frequency spectrum (Hertz)');
%Single-sided amplitude freq spectrum
subplot(3,1,2);
yy =fftshift(fft(y,N));
Amp =(abs(yy/N)); %Amplitude of modulated signal in Frequency spectrum
N_2 = ceil(N/2);
plot(f(1:N_2), Amp(1:N_2)); %continuous frequency spectrum
xlabel('Frequency (Hz)')
ylabel('Amplitude');
title('Single-sideband frequency spectrum (Hertz)');

Answers (1)

Daniel M
Daniel M on 28 Oct 2019
Why do you want a non-constant sampling frequency? I don't understand the advantages of that, and there are plenty of disadvantages.
Here is a working version of your code
clear
close all
clc
Em=5;
Ec=5;
fm=100;
fc=1000;
Tm=1/fm;
t=0:Tm/999:6*Tm; % Total time for modulated signal simulation (6 cycles will be displayed)
y= Ec*cos(2*pi*fc*t)+(Em/2)*cos(2*pi*(fc+fm)*t) + (Em/2)*cos(2*pi*(fc-fm)*t); % Equation of Amplitude modulated signal
N = length(y); %Number of samples
fs = (N-1)/t(end); %sampling frequency
% this is equivalent to 1/mean(diff(t))
f =(0:N-1)*(fs/N); %frequency range(Hz)
%Double-sideband frequency spectrum
figure(1);
subplot(2,1,1);
yy = fftshift(fft(y));
Amp =(abs(yy/N)); %Amplitude of spectrum
plot(f(1:N),Amp(1:N)); %continuous frequency spectrum
xlabel('Frequency (Hz)')
ylabel('Amplitude');
title('Double-sideband frequency spectrum (Hertz)');
%Single-sided amplitude freq spectrum
subplot(2,1,2);
yy =fftshift(fft(y,N));
Amp =(abs(yy/N)); %Amplitude of modulated signal in Frequency spectrum
N_2 = ceil(N/2);
plot(f(1:N_2), Amp(1:N_2)); %continuous frequency spectrum
xlabel('Frequency (Hz)')
ylabel('Amplitude');
title('Single-sideband frequency spectrum (Hertz)');
  2 Comments
Mai Sarah
Mai Sarah on 29 Oct 2019
Thank you so much on the coding. I want a non constant sampling frequency so that whatever value that I put in the AM signal equation (Em, fm, Ec, fc) is align with the theoretical output of an AM signal frequency spectrum. At least, that is where my logic is with this predicament. Em, fm, Ec and fc are intended to be user inputs in the full version of the coding. I can't seem to get my intended output if the fs is fixed. But please do enlightened me on the disadvantages of a non constant sampling frequency, if you want to. Again, thank you.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!