0% found this document useful (0 votes)
36 views1 page

Function

This MATLAB code illustrates the spectral representation of a 128 point sinusoidal signal with an amplitude of 1 and frequency of 12.5 Hz that is sampled at different sampling frequencies (Fs) and different FFT sizes (Nfft). It shows: a) Fs = 64 Hz, Nfft = 128 points b) Fs = 128 Hz, Nfft = 128 points c) Fs = 128 Hz, Nfft = 256 points

Uploaded by

Namikaze Nadine
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

Function

This MATLAB code illustrates the spectral representation of a 128 point sinusoidal signal with an amplitude of 1 and frequency of 12.5 Hz that is sampled at different sampling frequencies (Fs) and different FFT sizes (Nfft). It shows: a) Fs = 64 Hz, Nfft = 128 points b) Fs = 128 Hz, Nfft = 128 points c) Fs = 128 Hz, Nfft = 256 points

Uploaded by

Namikaze Nadine
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

function[]=DESAGUN

%Consider a 128 point sinusoid with the amplitude 1 and


frequency f = 12.5 Hz. This signal is sampled at Fs = 64 Hz or
Fs = 128 Hz. Its DFT is calculated on 128 or 256 points.
%Write a MATLAB code for illustrating the spectral
representation of the signals corresponding to the following
three cases:
%a. Fs = 64 Hz, Nfft = 128
%b. Fs = 128 Hz, Nfft = 128
%c. Fs = 128 Hz, Nfft = 256
t=(1:128); f1=12.5 ;Fs=64;
y1= sin(2*pi*f1/Fs*t); sig=y1; Nfft=128;
y=abs(((fft(sig,Nfft))));
f0=[0:Fs/Nfft:(Fs-Fs/Nfft)];
f1=12.5;Fs=128;
y1= sin(2*pi*f1/Fs*t); sig=y1; Nfft=128 ;
y_rect=abs(fftshift((fft(sig,Nfft))));
Nfft1=256;
y_rect1=abs(fftshift((fft(sig,Nfft1))));
f=[-Fs/2:Fs/Nfft:(Fs/2-Fs/Nfft)];
f1=[-Fs/2:Fs/Nfft1:(Fs/2-Fs/Nfft1)];
subplot(311); stem(f0,y);
grid; axis([0 64 0 80]);
title('Fs=64 kHz, Nfft=128 points');
ylabel('Spectral amplitude')
subplot(312)
stem(f(Nfft/2+1:Nfft),y_rect(Nfft/2+1:Nfft));
grid; axis([0 64 0 80]);
title('Fs=128 kHz, Nfft=128 points');
ylabel('Spectral amplitude')
subplot(313);
stem(f1(Nfft1/2+1:Nfft1),y_rect1(Nfft1/2+1:Nfft1));
grid; axis([0 64 0 80])
xlabel('frequency [Hz]');
ylabel('Spectral amplitude');
title('Fs=128 kHz, Nfft=256 points');

You might also like