how to script rectangular function in MATLAB

조회 수: 17 (최근 30일)
bora
bora 2023년 4월 26일
답변: John D'Errico 2023년 4월 26일
Which function should I use for a rectangular function in MATLAB?

답변 (1개)

John D'Errico
John D'Errico 2023년 4월 26일
Define what a rect function is, since I find it difficult to read your mind. I'll guess it might be a unit rectangular pulse of some sort. Perhaps this:
In that case, a rect function is simple enough to create, as the difference of two heaviside functions.
help heaviside
HEAVISIDE Step function. HEAVISIDE(X) is 0 for X < 0 and 1 for X > 0. The value HEAVISIDE(0) is 0.5 by default. It can be changed to any value v by the call sympref('HeavisideAtOrigin', v). See also DIRAC. Documentation for heaviside doc heaviside Other uses of heaviside sym/heaviside
For example:
rect = @(x) heaviside(x + 0.5) - heaviside(x - 0.5);
fplot(rect,[-2,2])
I've defined it there to be consistent with what mathworld shows.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by