Hey Joe
In order to convert a pulse that varies in frequency over time into a digital representation, you can use a combination of signal processing techniques and sampling. Given that the pulse starts at 10 kHz, rises to 10.1 kHz, and then falls back to 10 kHz, we can achieve this in MATLAB by generating a signal that reflects this behavior and then sampling it at the specified sample time of 1 ms (which corresponds to a sampling frequency of 1 kHz).
Kindly refer to following MATLAB code to get better understanding.
% Define parameters
fs = 1e3; % Sampling frequency (1 kHz)
t = 0:1/fs:1; % Time vector from 0 to 1 second with 1 ms increments
% Define the frequency profile
f_start = 10e3; % Starting frequency (10 kHz)
f_peak = 10.1e3; % Peak frequency (10.1 kHz)
f_end = 10e3; % Ending frequency (10 kHz)
% Generate the frequency-varying pulse
% Assuming the pulse duration is 1 second and the frequency change happens linearly
half_length = length(t)/2;
f = [linspace(f_start, f_peak, half_length), linspace(f_peak, f_end, half_length)];
% Ensure the frequency vector has the same length as the time vector
if length(f) < length(t)
f = [f, f_end]; % Append the ending frequency to match lengths
end
% Generate the signal
signal = sin(2 * pi * f .* t);
% Plot the original signal
figure;
subplot(2, 1, 1);
plot(t, signal);
title('Frequency-Varying Pulse');
xlabel('Time (s)');
ylabel('Amplitude');
% Sample the signal at 1 kHz
sampled_signal = signal(1:fs:end);
% Define the time vector for the sampled signal
sampled_time = t(1:fs:end);
% Plot the sampled signal
subplot(2, 1, 2);
stem(sampled_time, sampled_signal, 'filled');
title('Sampled Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Display sampled signal values
disp('Sampled Signal Values:');
disp(sampled_signal);