Plotting the heaviside discontinuity function
12 次查看(过去 30 天)
显示 更早的评论
The plot generated by the following code is not always the same and sometimes somewhat inaccurate. For example, there should be a vertical line at x = 0 from y = 0 to y = 8 but the line sometimes has a slight slope and the y values don't always exactly match the correct values.
syms x
f = 8*heaviside(x) - 8*(heaviside(x).*x-heaviside(x-4).*(x-4).^1)+40*(heaviside(x-4).*(x-4).^0)-16*heaviside(x-6).*(x-6).^0;
fplot(f,[0 6])
How can one generate a precise plot rather than one that is based on approximations?
0 个评论
采纳的回答
Walter Roberson
2020-10-13
Start the plot slightly below 0 so as to give it a chance to see the full discontinuity at 0.
syms x
f = 8*heaviside(x) - 8*(heaviside(x).*x-heaviside(x-4).*(x-4).^1)+40*(heaviside(x-4).*(x-4).^0)-16*heaviside(x-6).*(x-6).^0;
xlim([-1, 7]); ylim([-5 20]); hold on
fplot(f,[-1 6])
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!