필터 지우기
필터 지우기

improving result of FFT

조회 수: 3 (최근 30일)
imran khan
imran khan 2019년 11월 5일
댓글: imran khan 2019년 11월 7일
Dear fellows i want to achieve good frequency resolution by adding this command in my code n = 2^nextpow2() but i dont know how to add in my code can anybody help me please.please don't change sampling frequency=36000 and bode=1000.
clc,close all,clear all
codn=100;
% fc=6e+3;
fs=36000;
bode=1000;
code=round(rand(1,codn));
code_len=round(1/bode/(1/fs))
for ii=1:codn
x((ii-1)*code_len+1:code_len*ii)=code(ii)
end
x2 = x-(1/2) % get rid of most of the dc peak
% set up time and frequency arrays
length(x)
N = length(x)
delt = 1/fs;
delf = fs/N;
tvec = (1:N)*delt;
fvec = (-N/2:N/2-1)*delf ; % shifted frequency array
figure(1)
plot(tvec,x2(1,:)+0.5)
title('orignal baseband')
xlabel('time');
ylabel('amplitude')
ylim([-1 1.5]);
y = fftshift(fft(x2/N));
z=abs(y);
figure(2)
plot(fvec,abs(y))
title('FFT')
xlabel('frequency')
ylabel('amplitude')
figure(3)
z=y;
z(abs(fvec)>=50& abs(fvec)<=150)=0
plot(fvec,abs(z))
xlabel('frequency removed from 50 to 150 HZ');
ylabel('amplitude')
figure(4)
zf=fftshift(z)*N;
zifft=ifft(zf)+0.5;
plot(tvec,abs(zifft))
ylim([-1 1.5])
title('recovered signal')
xlabel('time');
ylabel('amplitude')

답변 (1개)

Daniel M
Daniel M 2019년 11월 5일
You'll want to use it as the second input to the fft. This will affect your frequency vector fvec though.
n = 2^nextpow2(N);
y = fftshift(fft(x2,n)); % you can choose to normalize x2 by 1/n if you want
  댓글 수: 5
Daniel M
Daniel M 2019년 11월 6일
You can follow the second example on the document page for fft. It will demonstrate it more clearly than I will here.
imran khan
imran khan 2019년 11월 7일
Dear danieli have taken the idea from matlab example which you send me in your link and i modified it but the problem is that i can't rectify me error

댓글을 달려면 로그인하십시오.

카테고리

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