Asked by Aniket
on 5 Feb 2013

hello i don't want to use chirp inbuilt function and i have written a code for chirp. could any one tell me is the code is correct ? i have simulate it and getting plot but at instantaneous time t1, I am not getting frequency change.

i have written a code according to equation of chirp signal generation.

please tell me this is correct ?

*********************************************

f1 =10;

f2 = 50 ;

t =0:0.001:20;

t1 = 10;

alpha = (f2-f1)/t1;

f= (alpha)*t + f1;

xx =1*cos(f);

plot (t,xx);

**************************************************

*No products are associated with this question.*

Answer by Youssef Khmou
on 5 Feb 2013

Edited by Youssef Khmou
on 5 Feb 2013

Accepted answer

hi, try this :

Fs=1000; % sample rate tf=2; % 2 seconds t=0:1/Fs:tf-1/Fs; f1=100; f2=400; % start @ 100 Hz, go up to 400Hz semi_t=0:1/Fs:(tf/2-1/Fs); sl=2*(f2-f1/2); f1=f1*semi_t+(sl.*semi_t/2); f2=f1(end)+f2*semi_t-sl.*semi_t/2; f=[f1 f2]; y=1.33*cos(2*pi*f.*t); plot(t,y)

To check the Amplitude spectrum (100Hz,400Hz), try my submission : http://www.mathworks.com/matlabcentral/fileexchange/40002-psd-power-spectral-density-and-amplitude-spectrum-with-adjusted-fft

Show 1 older comment

Youssef Khmou
on 7 Feb 2013

hi, consider the slope as :

K=f2-f1/2 ; then :

f1=f1*semi_t+(K*semi_t);

f2=f1(end)+f2*semi_t-(K*semi_t);

We added "f(end)" to have continuity in the frequency , to test do this :

f1=f1*semi_t+(K*semi_t);

f2=f2*semi_t-(K*semi_t);

f=[f1 f2]; plot(t,f)

Youssef Khmou
on 24 Aug 2013

hi vamsi,

Your parameters do not fit the last example because of scaling problem; the frequency continues to increase or cant reach the final value f2 . To overcome this issue, consider the frequency as function **F=at+constant** that when time ends F=f2 and when time starts F=f1 :

Fs=500e6; f=5e-6; t=0:1/Fs:tf-1/Fs; f1=160e6 ; f2=170e6; SLOPE=(f2-f1)./t(end); F=f1+SLOPE*t; y=1.33*cos(2*pi*F.*t); plot(t,y) fy=fft(y); Freq=(0:length(t)-1)*Fs/length(t); figure, plot(Freq(1:end/2),abs(fy(1:end/2)))

Have you ever used the function **chirp(t,f0,t1,f1)** ?

Opportunities for recent engineering grads.

## 0 Comments