# Problem with amplitude and smoothness of FFT

2 views (last 30 days)
Amy Lg on 10 Jan 2022
Edited: Amy Lg on 16 Jan 2022
Hi,
I am trying to create 10 individual signals with on-off keying modulation format, add them up to have a final signal, and then take a Fourier transform of that signal. I tried to zero padd the final signal before taking fft so that I can correct amplitude for my spectrum based on this link:
However, I still do not get amplitude one for frequencies of interest.
clc, clear all, close all;
NStep = 20; % the number of bits
R = 20; % Bit rate (Gbps)
Tr = 1/R; % bit period (nanosecond)
fc = [195.89e3 195.79e3 195.69e3 195.59e3 195.49e3 195.39e3 195.29e3 195.19e3 195.09e3 194.99e3]; %carrier freq.(GHz)
Signal = 0;
for Iter = 1:numel(fc)
Fc = fc(Iter); % Carrier frequency
x = randi([0,1],1,NStep); % Binary information as stream of bits (binary signal 0 or 1)
N = length(x);
nb = 1e6; % Digital signal per bit
t = Tr/nb:Tr/nb:nb*N*(Tr/nb); % Time period (ns)
Digit = [];
for n = 1:1:N
if x(n) == 1;
sig = ones(1,nb);
else x(n) == 0;
sig = zeros(1,nb);
end
Digit = [Digit sig];
end
mod = Digit .* cos(2*pi*Fc*t);
Signal = Signal + mod; % final signal
end
subplot(2,1,1)
plot(t,Signal);
xlabel('Time (ns)');
ylabel('Amplitude');
title('OOK Modulated Signal');
%% fft
xdft = xdft/length(Signal);
xdft(2:end-1) = 2*xdft(2:end-1); %multiply all frequencies except 0 and the Nyquist by 2.
fs = 1/(Tr/nb);
subplot(2,1,2)
plot(freq,abs(xdft)/max(abs(xdft)))
axis([194.94e3 195.94e3 0 1]);
xlabel('Frequency (GHz)');
ylabel('Amplitude');
title('FFT of final Signal');

Paul on 12 Jan 2022
The time domain signal, Signal, is not a sum of pure cosines because of how Digit is calculated, so we shouldn't expect its fft to be "nice."
Change this line
% mod = Digit .* cos(2*pi*Fc*t); % OOK Modulation
mod = cos(2*pi*Fc*t); % OOK Modulation
and the result will be very nice, which illustrates the effect of Digit.
Amy Lg on 14 Jan 2022
Sometimes the amplitude of the spectrum for a peak is very low and this can make problem in my system later on.