DSPRelated.com
Forums

FFT Chirp Problems MATLAB

Started by kyletae June 2, 2006
I am doing an FFT of a chirp function.

I am having problems with realizing the FFT! The FFT should when p =1 look
like the signal in. It doesn't Any suggestions?! Thanks...


The following is the m-code:

function s = dtFMchirp(p,TW)

% DCHIRP generate a sampled chirp signal
% usage s = dchirp(TW,p)
% s : samples of a digital "chirp" signal 
% 	exp(j(W/T)pi*t^2)  -T/2 <= t < T/2
% TW : time-bandwidth product
% p : sample at p times the Nyquist rate (W)
%p=10;
%TW=50;
%N = p*TW;
%n = 0:N;
%alpha = 1/(2*p*p*TW);
%s = exp(j*2*pi*alpha*((n-.5*N).^2));
%x=real(s);
%plot(x);
%length1=length(x);
%figure;
%fftx=fft(x,length1);
%fftx=abs(fftx);
%plot(fftx);
close all;
clear;
p=1;
TW=50;
N = p*TW;
n = 0:N;
alpha = 1/(2*p*p*TW);
s = exp(j*2*pi*alpha*((n-.5*N).^2));
figure(1); 
x=real(s);
plot(x);
length1=length(x);

fftx=fft(x,length1);
k=round(length1/2);
fftx=[fftx(k:end) fftx(1:k)];
fftx=abs(fftx);
fftx=abs(20*log10(fftx));
x=-2:4/length1:2;
figure(3)
plot(fftx);





"kyletae" <kyletae@gmail.com> wrote in message 
news:m6-dnUuLDphvsR3ZnZ2dnUVZ_vSdnZ2d@giganews.com...
>I am doing an FFT of a chirp function. > > I am having problems with realizing the FFT! The FFT should when p =1 look > like the signal in. It doesn't Any suggestions?! Thanks...
<...> It looks like your smallest phase increment is 2*pi , this will cause problems. Best of Luck - Mike
"Mike Yarwood" <mpyarwood@btopenworld.com> wrote in message 
news:haednfXDS6deph3ZnZ2dnUVZ8qOdnZ2d@bt.com...
> > "kyletae" <kyletae@gmail.com> wrote in message > news:m6-dnUuLDphvsR3ZnZ2dnUVZ_vSdnZ2d@giganews.com... >>I am doing an FFT of a chirp function. >> >> I am having problems with realizing the FFT! The FFT should when p =1 >> look >> like the signal in. It doesn't Any suggestions?! Thanks... > <...> > It looks like your smallest phase increment is 2*pi , this will cause > problems.
Acchh! No it's not - I forgot the alpha.. Best of luck- Mike
kyletae wrote:
> I am doing an FFT of a chirp function. > > I am having problems with realizing the FFT! The FFT should when p =1 look > like the signal in.
Where is signal in? or in where? It doesn't Any suggestions?! Thanks...
> > > The following is the m-code: > > function s = dtFMchirp(p,TW) > > % DCHIRP generate a sampled chirp signal > % usage s = dchirp(TW,p) > % s : samples of a digital "chirp" signal > % exp(j(W/T)pi*t^2) -T/2 <= t < T/2 > % TW : time-bandwidth product > % p : sample at p times the Nyquist rate (W) > %p=10; > %TW=50; > %N = p*TW; > %n = 0:N; > %alpha = 1/(2*p*p*TW); > %s = exp(j*2*pi*alpha*((n-.5*N).^2)); > %x=real(s); > %plot(x); > %length1=length(x); > %figure; > %fftx=fft(x,length1); > %fftx=abs(fftx); > %plot(fftx); > close all; > clear; > p=1; > TW=50; > N = p*TW; > n = 0:N; > alpha = 1/(2*p*p*TW); > s = exp(j*2*pi*alpha*((n-.5*N).^2)); > figure(1); > x=real(s); > plot(x); > length1=length(x); > > fftx=fft(x,length1); > k=round(length1/2); > fftx=[fftx(k:end) fftx(1:k)]; > fftx=abs(fftx); > fftx=abs(20*log10(fftx)); > x=-2:4/length1:2; > figure(3) > plot(fftx);
The signal is the real part of the following:
>> p=1; >> TW=50; >> N = p*TW; >> n = 0:N; >> alpha = 1/(2*p*p*TW); >> s = exp(j*2*pi*alpha*((n-.5*N).^2));
it basically is creating a chirp. When p=1 the FFT should look like the actual signal. Now this line
>> fftx=[fftx(k:end) fftx(1:k)];
is turning the middle to the far left and the middle to the far right and adding them together to create a function of what it is supposed to look like. I'm trying to make it look like this website: http://cnx.org/content/m11718/latest/ My chrip function very similar but the FFT comes up strange! :( ----------------------old crap of the post--------
> >kyletae wrote: >> I am doing an FFT of a chirp function. >> >> I am having problems with realizing the FFT! The FFT should when p =1
look
>> like the signal in. > >Where is signal in? or in where? > >It doesn't Any suggestions?! Thanks... >> >> >> The following is the m-code: >> >> function s = dtFMchirp(p,TW) >> >> % DCHIRP generate a sampled chirp signal >> % usage s = dchirp(TW,p) >> % s : samples of a digital "chirp" signal >> % exp(j(W/T)pi*t^2) -T/2 <= t < T/2 >> % TW : time-bandwidth product >> % p : sample at p times the Nyquist rate (W) >> %p=10; >> %TW=50; >> %N = p*TW; >> %n = 0:N; >> %alpha = 1/(2*p*p*TW); >> %s = exp(j*2*pi*alpha*((n-.5*N).^2)); >> %x=real(s); >> %plot(x); >> %length1=length(x); >> %figure; >> %fftx=fft(x,length1); >> %fftx=abs(fftx); >> %plot(fftx); >> close all; >> clear; >> p=1; >> TW=50; >> N = p*TW; >> n = 0:N; >> alpha = 1/(2*p*p*TW); >> s = exp(j*2*pi*alpha*((n-.5*N).^2)); >> figure(1); >> x=real(s); >> plot(x); >> length1=length(x); >> >> fftx=fft(x,length1); >> k=round(length1/2); >> fftx=[fftx(k:end) fftx(1:k)]; >> fftx=abs(fftx); >> fftx=abs(20*log10(fftx)); >> x=-2:4/length1:2; >> figure(3) >> plot(fftx); > >