Up Chirp and Down Chirp Generation in a Single plot
22 views (last 30 days)
Show older comments
I am trying to generate a chirp signal with both up chirp and down chirp for one of my project, upchirp - which has start frequency of 57 GHz and Bandwidth of 150MHz then after 2microseconds and again have to generate down chirp with the same bandwidth and frequency
2 Comments
Answers (1)
Mathieu NOE
on 20 Feb 2026 at 10:39
hello
well there is the documentation related to the chirp funtion, have you looked here ? chirp - Swept-frequency cosine - MATLAB
I can suggest this code :
NB : the first plot is just to show the ending portion of the up chirp signal (in blue) with the first samples of the down chirp signal (in red) - which is simply the time mirrored copy of the up chirp. I also aplied a sign inversion because then the transition is smooth between the two. It's a very simple trick that works here but may fail with other input parameters - you may improve this by checking if the up chirp signal stops with a positive or negative end point (and slope) and truncate accordingly to have the smooth transition)
I notice also that the frequency variation is very low (can be visualized in the spectrogram too) so I wonder if the starting freq is 57 or 5.7 GHz.
code :
BW = 150e6; % Hz
f_low = 57e9; % Hz
f_up = f_low + BW; % Hz
t_up = 2e-6; % up chirp duration
% choose a sampling rate in power of 2
n = nextpow2(f_up)+3;
Fs = 2^n;
dt = 1/Fs;
% up chirp
t = 0:dt:t_up; % Time vector
phi = 90; % Initial phase in degrees
y = chirp(t, f_low, t_up, f_up,"linear",phi); % Generate chirp signal
% figure,plot(y(1:25)); % Plot the chirp signal beginning to actually check
% it starts with 0
% add time flipped version of y (downchirp)
% the neg sign is a trick to ensure a continous and smooth transition
% between the up and down chirps
y_down = -fliplr(y);
nn = 25;
xx = 1:nn;
figure,plot(xx,y(end-nn+1:end),'b*-',xx+nn,y_down(1:nn),'r*-') % Plot the chirp signal ending portion
% combine up and down chirps
y = [y y_down];
% spectrogram
Ndft = 1024*16;
overlap = 0.75;
L = round(overlap*Ndft);
g = bartlett(Ndft);
[s,f,t] = spectrogram(y,g,L,Ndft,Fs);
s_dB = 20*log10(abs(s));
% display the spectrogram, defined as the magnitude squared of the STFT.
figure
imagesc(t,f,s_dB)
set(gca,YDir="normal");
colorbar
clim([max(s_dB(:))-60 max(s_dB(:))])
ylim([0.99*f_low 1.01*f_up])
shading interp
See Also
Categories
Find more on Pulsed Waveforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
