Replicating a plot over multiple periods in the same figure
显示 更早的评论
I have a piecewise function defined by the following:
v = @(t,a,b) (t>=a) & (t<b);
f=@(t) 0.*v(t,-1,0) + 2*t.*v(t,0,0.5) + 0.*v(t,0.5,0.5) +...
(2*t-2).*v(t,0.5,1) + 0.*v(t,1,2)
t=[0:0.01:1];
I can plot this function over the interval (0,1), but I need to plot it over several intervals, while maintaining the shape and values of the function.
Note: The lower and upper limits of t in the function can be increased and decreased.
Thanks all.
1 个评论
Walter Roberson
2011-11-4
You might as well simplify your function to
f = @(t) 2*t.*v(t,0,0.5) + (2*t-2).*v(t,0.5,1)
as the 0.* parts are never going to add anything to the sum.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Stair Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!