Reputation: 1
I have:
h(t):=piecewise(0<=t<2,2-t,2<=t<=3,2t-4)
Then I use:
plot(h(t),t=0..6,y=-1..3,scaling=constrained)
My intention was to create a period of 2 by making a larger interval. This didn't solved my problem.
How would I be able to create two periods in the plot?
Upvotes: 0
Views: 576
Reputation: 7271
Hopefully I've understood the goal.
restart;
h:=t->piecewise(0<=t and t<2,2-t,2<=t and t<=3,2*t-4):
H:=proc(t,p::realcons)
local P,T;
if not t::realcons then
return 'procname'(args);
end if;
P:=evalf(p);
T:=frem(t-P/2,P)+P/2;
h(T);
end proc:
plot(H(t,3), t=0..6, y=-1..3);
plot(H(t,3), t=-12..12, y=-1..3);
Upvotes: 0