Assume you have 4000 samples of a signal that has been sampl
Assume you have 4000 samples of a signal that has been sampled at 20 kHz. Define and calculate the sampling period, total sampling period time, and frequency step for the FFT (fast fourier transform in MATLAB). Assuming that you perform an FFT in MATLAB, explain the steps that you will take in order to visualize the spectrum. What units would you have on the axes, and what physical quantities do they depict? What numbers would you put in them?
Solution
close all;
clear all;
clc;
N=4000;
n=0:1:N-1;
x=sin(2*pi*n/20)+sin(2*pi*n/15);
D=2;
x1=x(1:D:N);
n1=1:1:N/D;
subplot(2,1,1);
stem(n,x);
xlabel(\'n\');
ylabel(\'x\');
title(\'input sequence\');
subplot(2,1,2);
stem(n1-1,x1);
xlabel(\'n\');
ylabel(\'x1\');
title(\'downsampled sequence\')
clear all;
close all;
clc;
x1=input(\'enter the first sequence\');
x2=fliplr(x1);
l=length(x1);
x1=fft(x1);
x2=fft(x2);
f=x1.*x2;
j=ifft(f);
subplot(2,2,1);
stem(x1);
xlabel(\'input sequence\');
ylabel(\'amplitude\');
title(\'input sequence\');
subplot(2,2,2);
stem(j);
xlabel(\'time\');
ylabel(\'amplitude\');


