MATLAB: Linear chirp signal generation

chirp

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);
**********************************************

Best 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)