Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

trying to make a chirp (sweep) in matlab

1,516 views
Skip to first unread message

Zac

unread,
Oct 26, 2008, 1:41:01 AM10/26/08
to
Hey guys. So i'm trying to make a chirp function where you pass it the arguements :

sweep(startFreq, endFreq, timeLength, amplitude, Fs)

and it creates a sweep(chirp) that goes from the start frequency to the end frequency in timeLength/2, and then back to the starting frequency. So the total sweep time to go from start frequency to end frequency and back takes timeLength. I'm not entirely sure how to create a sweep though...suggestions/help?

Idin Motedayen-Aval

unread,
Oct 26, 2008, 10:43:48 AM10/26/08
to

Try the CHIRP function from the Signal Processing Toolbox.
If you don't have Sig Proc Tlbx, you can do it manually. Create the
vector of time values (0:1/Fs:timeLength), then create the vector of
frequencies at those instances and use cos().

HTH,
Idin

ZK

unread,
Oct 26, 2008, 3:05:03 PM10/26/08
to
Idin Motedayen-Aval <run.si...@MATLAB.for.email> wrote in message <ge1vne$p1f$1...@fred.mathworks.com>...

I looked at the chirp command and for some reason in simulink you can do a bidirectional chirp which is what i want to do, but you can't do one in the regular code. I tried to actually do it the way you described using cos() and i just can't get it to work out for whatever reason.

ZK

unread,
Oct 26, 2008, 7:21:01 PM10/26/08
to
my code is:

Fs = 8000; % sampling freq.
T = 1/Fs;
f1 = 10; % initial frequency in chirp
f2 = 20; % final frequency in chirp
tfinal = 3; % duration
amplitude = 1;

tHALF = 0:T:(tfinal/2 - T); % half the time function (length of sweep each way)
m = (f2 - f1)/(tfinal/2); % chirp slope

% create the "frequency" function
f1 = f1 + (m*tHALF);
f2 = f2 - (m*tHALF);
f = [f1 f2];

t = 0:T:tfinal - T; % time function
y = amplitude*cos(2*pi*f.*t);


for some reason it doesn't look right when i plot(t,y) but the values of f and t seem correct...

Idin Motedayen-Aval

unread,
Oct 27, 2008, 2:47:53 PM10/27/08
to

ZK,
The instantaneous frequency is the derivative of the phase. I haven't
played around with this too much... but try this in your code:
f1 = f1*tHALF + (m*tHALF).*tHALF/2;
f2 = f1(end)+f2*tHALF - (m*tHALF).*tHALF/2;
f = [f1 f2(2:end)];

Now doing a
spectrogram(y,hamming(128),110,[],8000)
shows a pretty clean bidirectional sweep (note that I'm avoiding a
discontinuity in the phase by making sure f2 starts where f1 leaves
off... and make sure no repeat values!)

You could also do something like this:
y1 = chirp(tHALF,10,tHALF(end),1000,'linear');
y2 = chirp(tHALF,1000,tHALF(end),10,'linear',rad2deg(acos(y1(end))));
y = [y1 y2(2:end)];
spectrogram(y,hamming(128),110,[],8000)
(Again, avoid phase discontinuity by using the ending phase of y1 as
initial phase of y2)

HTH,
Idin

--
Idin Motedayen-Aval
The MathWorks, Inc.
zq=[4 2 5 -15 -1 -3 24 -57 45 -12 19 -12 15 -8 3 -7 8 -69 53 12 -2];
char(filter(1,[1,-1],[105 zq])), clear zq

Alan Armstrong

unread,
Aug 13, 2012, 11:27:05 AM8/13/12
to
Hi,

I tried to use the second code you presented below expect with the frequencies 200Hz and 700Hz and i still get a small glitch at the end of y1 and the beginning of y2. You can hear a small click. Is this because of the frequencies that I'm using because i don't hear the glitch when I use your frequencies of 10-100Hz?

thanks,

Alan

Idin Motedayen-Aval <run.si...@MATLAB.for.email> wrote in message <ge52cq$p8a$1...@fred.mathworks.com>...

fp...@intellecttech.net

unread,
May 30, 2016, 3:18:47 AM5/30/16
to
Dear sir/madam,

I am working in implementation of chirp slope keying modulation and demodulation in MATLAB.

Simulations that completed are:

1. Chirp signal(up and down chirp) generation completed

2. LFM with up-chirp and down-chirp also simulated

3. Random bit of data generation completed

4. finally, i need to simulate the CSK MODULATED SIGNAL.


but i got struck in the csk modulated signal.

I am getting the plots of up-chirp and down-chirp signals .

my doubt is: how to combine/add those two chirp signals in MATLAB.

Could you please give me guidance for how to write the logic.


Is there any related information is there then please mail me .

my mail id : pavani.int...@gmail.com

Hope you reply me soon . am eagerly waiting for your reply.
0 new messages