Please help me make this function periodic

3 views (last 30 days)
Vinh Le
Vinh Le on 17 Feb 2019
Answered: Bjorn Gustavsson on 27 Feb 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)

Answers (2)

Agnish Dutta
Agnish Dutta on 27 Feb 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 on 27 Feb 2019
Write a function for that pulse shape, then have a look at the pulstran function.
HTH

Community Treasure Hunt

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

Start Hunting!