How to generate a periodic customized waveform?

7 visualizaciones (últimos 30 días)
Jay Vaidya
Jay Vaidya el 6 de Ag. de 2021
Editada: Yazan el 7 de Ag. de 2021
I want to generate waveforms as shown in the image below and then tweak them to modify the fall time constant of the signal. However, MATLAB doesn't have a customized waveform generator I think. Can I make this waveform in MATLAB? Thanks in advance!

Respuesta aceptada

Yazan
Yazan el 6 de Ag. de 2021
Editada: Yazan el 7 de Ag. de 2021
This simple function can compute the signal you need. Use lambda to control the decay and see the other parameters.
function x = mySignal(T1, T2, A, lambda, np)
if nargin==0
T1 = 10; T2 = 30; A = 5; lambda = 0.25; np = 5; % np is number of periods
end
t1 = 0:T1-1; t2 = (T1:T2);
x1 = A/(T1-0).*t1;
x2 = A.*exp(-lambda.*(t2-T1));
xx = [x1(:); x2(:)];
x = repmat(xx, [np, 1]);
t = 0:length(x)-1;
figure, plot(t, x), grid minor
ax = gca;
ax.XTick = [0, T1, T2];
ax.XTickLabel = {'0', sprintf('T1=%g', T1), sprintf('T2=%g', T2)};
ax.YTick = [0, A];
ax.YTickLabel = {'0', sprintf('A=%g', A)};
title({'Composite signal', 'Control exponential decay by $\lambda$'}, 'interpreter','latex')
end

Más respuestas (0)

Categorías

Más información sobre Signal Processing Toolbox en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by