Non constant Sampling Frequency in FFT of Amplitude Modulation
8 views (last 30 days)
Show older comments
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)');
0 Comments
Answers (1)
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
Daniel M
on 29 Oct 2019
Edited: Daniel M
on 29 Oct 2019
It's just an added layer of complexity that isn't normally there. Here is a good tutorial on your problem. <https://dsp.stackexchange.com/questions/32137/frequency-analysis-of-a-signal-without-a-constant-sampling-frequency-non-unifor>
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!