Borrar filtros
Borrar filtros

Please help me make this function periodic

1 visualización (últimos 30 días)
Vinh Le
Vinh Le el 17 de Feb. de 2019
Respondida: Bjorn Gustavsson el 27 de Feb. de 2019
Thank you very much for all the help!
T = 1 millisecond
Vm = 1 volt (amplitude voltage)
t = linspace(-T, 2*T, 3001)
The following pararameter is given
v(t) = Vm - (Vm/T)t for 0<= t <= T
0 elsewhere
I need to modify the vector v so that is represents a periodic function with a period T over this time period
(hint: it should look like a sawtooth), and plot v vs t over the range from -T to 2T.
So far I have this:
T = 1;
Vm = 1;
t = linspace(-T,2*T,3001);
for i = 1:length(t)
if (t(i) >= 0) && (t(i) <= T)
v(i) = Vm - (Vm/T)*t(i);
else
v(i) = 0;
end
end
plot(t,v)

Respuestas (2)

Agnish Dutta
Agnish Dutta el 27 de Feb. de 2019
You can repeat copies of an array along any dimension using the 'repmat()' function. This will allow you to generate a periodic function. The following link contains the documentation for the same:
In addition, refer to the following MATLAB answer link which has a query of the same nature as the one you've asked. Go through the accepted answer.

Bjorn Gustavsson
Bjorn Gustavsson el 27 de Feb. de 2019
Write a function for that pulse shape, then have a look at the pulstran function.
HTH

Categorías

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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by