Unitstep Function (Heaviside Function) Plotting Help
3 次查看(过去 30 天)
显示 更早的评论
I am working with Matlab and I am trying to create a unitstep function using the heavistep function. My code is shown below.
%f(x) = 0 for x<0 and f(x) = 1 for x>=1
function unit = unitstep(t)
unit = heaviside(t);
After creating this file I used the following commands in the command window.
t = -20:0.001:20;
plot (unitstep(t));
When I plot the unitstep function I created I get the below image. My question is why does the graph rise to y = 1 at x = 2 instead of at x = 0?
My plot.

Expected Output plot

0 个评论
采纳的回答
Star Strider
2020-9-3
There appears to be missing information, specifically because in the top plot it is not rising at
, it is instead rising at
.
This produces the desired result:
unitstep = @(t) t>0;
t = -20:0.001:20;
figure
plot(t, unitstep(t))
axis([min(t)-0.1 max(t)+0.1 -0.1 1.1])
grid
.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulation, Tuning, and Visualization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!