# question with chirped signal

I have some difficulty understanding the following question. I have written a code to plot continuous and discrete version of the chirped signal.

import numpy as np
from scipy.signal import chirp, spectrogram
import matplotlib.pyplot as plt
%matplotlib qt
N = 400
t = np.linspace(0, 2, N)
f0  = 0
f1 = 10
t1= 2
Fs = 8000
n = np.arange(N)
alpha = (f1 - f0)/t1
w = np.cos(2*np.pi*f0*t + np.pi*alpha*t**2)
plt.plot(t, w)
w_d = np.cos(2*np.pi*f0*n/Fs + np.pi*alpha*(n**2)/Fs)
plt.plot(n / (N/2),w_d, 'ro')


Although N is completely taken randomly. It gave me a smooth curve for a continuous version. I don't know if my plot is correct or not. However, I am stuck now. what does the question mean? How to find the counts crossing the absicca? For zero-crossing, as far as I understood, the count would vary for N? I'd appreciate it if anyone could help me understand the question.

• What happens with the spectrum when sampled at a certain frequency? Mar 27, 2021 at 18:35
• N should be 16000: $N = F_s * t_1 = 8000 * 2$.
– IanJ
Mar 27, 2021 at 19:28

I can't interpret numpy code, but I don't think you should define an 'N' variable. For a 2-second signal you should have a total of 16000 samples. Here's how to do this in MATLAB (notice how I defined my "number of samples" variable ('Num_Samples')):

Fs = 8000;
Ts = 1/Fs; % Time between samples
T1 = 2; % Signal duration = two seconds
F0 = 0; % Start frequency
F1 = 10; % Stop frequency (at T1 seconds)
Num_Samples = 2/Ts; % Two seconds divided by 'Ts'
n = 0:Num_Samples-1; % Here's your time-domain index
Alpha = (F1-F0)/T1;
X = cos(2*pi*F0*n*Ts + Alpha*pi*(n*Ts).^2);

figure(1)
plot(n*Ts, X, '-bs'), grid on


Finding the number of zero-crossings in the 2 second duration of your chirp signal is nothing more than examining each generated 'x(nTs)' sample (starting with the 2nd sample) and seeing if its polarity is different from the previous 'x((n-1)Ts)' sample. Each time a polarity difference occurs you have a single zero-crossing.