Non constant Sampling Frequency in FFT of Amplitude Modulation

3 次查看(过去 30 天)
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)');

回答(1 个)

Daniel M
Daniel M 2019-10-28
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 个评论
Mai Sarah
Mai Sarah 2019-10-29
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by