Convert pulse to digital

2 visualizaciones (últimos 30 días)
Joe Miller
Joe Miller el 13 de Mayo de 2018
Respondida: Anurag Ojha el 13 de Ag. de 2024
Dear Sir/Madam, If i represent a pulse with y-axis as time and x-axis as frequency is it possible to convert that pulse into a digital representation having a period that changes with increase in frequency. The figure shows a pulse that starts at 10KHz rises to 10.1KHz then falls back to 10KHz. The sample time for discussion has been set to 1ms.
Regards Joe

Respuestas (1)

Anurag Ojha
Anurag Ojha el 13 de Ag. de 2024
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:');
Sampled Signal Values:
disp(sampled_signal);
1.0e-12 * 0 -0.9714

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by