Triangular wave form with skew and delay period

16 visualizaciones (últimos 30 días)
Karthik K
Karthik K el 20 de Ag. de 2020
Respondida: Suraj Kumar el 11 de Abr. de 2025
Hi all, I need Matlab code to generate triangular waveform with .85 skew and time delay period between two cycles. I know how to generate triangular pulse but i needed in wave form. I tried with pulstran but it is not coming properly.
Please help me. Thank you in advance

Respuestas (1)

Suraj Kumar
Suraj Kumar el 11 de Abr. de 2025
Hi Karthik,
To generate a triangular waveform with a specified skew and delay period in MATLAB, we should initially define the necessary parameters such as sampling frequency, period, skew factor, delay period, and total duration. Then, we can create a time vector covering the desired duration.
Fs = 1000;
T = 1;
skew = 0.85;
delay_period = 0.2;
duration = 5;
t = 0:1/Fs:duration;
Then we can use the `sawtooth` function in MATLAB with the skew factor to generate the triangular waveform.
tri_wave = sawtooth(2 * pi * t / T, skew);
Finally, we can introduce a delay between cycles by zeroing out parts of the waveform corresponding to the delay period, ensuring that the waveform is only active during each cycle's defined period.
delay_samples = round(delay_period * Fs);
wave_with_delay = zeros(size(t));
for i = 1:length(t)
cycle_index = floor(t(i) / (T + delay_period));
time_in_cycle = t(i) - cycle_index * (T + delay_period);
if time_in_cycle <= T
wave_with_delay(i) = sawtooth(2 * pi * time_in_cycle / T, skew);
end
end
figure;
plot(t, wave_with_delay);
xlabel('Time (s)');
ylabel('Amplitude');
title('Triangular Waveform with Skew and Delay');
To learn more about 'sawtooth' function in MATLAB, please refer to the following documentation:

Community Treasure Hunt

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

Start Hunting!

Translated by