필터 지우기
필터 지우기

Plotting the heaviside discontinuity function

조회 수: 4 (최근 30일)
Aleem Andrew
Aleem Andrew 2020년 10월 13일
댓글: Aleem Andrew 2020년 10월 13일
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?

채택된 답변

Walter Roberson
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 CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by