Plot unit step function
4 次查看(过去 30 天)
显示 更早的评论
I'm trying to plot the signal u(t)-u(t-1) without heaviside in MATLAB. I've tried to use the if loop but couldn't figure it out.
采纳的回答
Star Strider
2018-10-3
You can use a ‘logical indexing’ approach:
ustp = @(t) +(t>0); % Simple Unit Step Function
t = linspace(-5, 5);
figure
plot(t, ustp(t)-ustp(t-1))
grid
I will let you figure out how it works.
3 个评论
Vicky
2023-9-19
Can you explain how you wrote "@(t) +(t>0)"? It worked perfectly but I'm unsure what the @ is doing here. Thank you so much!
Star Strider
2023-9-19
@Vicky — That is an anonymous function. It works the same way other functions do, and can be called similarly. The ‘@’ creates its function handle.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Pie Charts 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!