Function Handle for a Rectangular Function

Would it be possible to create a function handle for a rectangular function defined as follows?
Thanks.

 採用された回答

Voss
Voss 2022 年 4 月 12 日

0 投票

% rect = @(t)double(0<=t & t<=1); % returns double array (1/0)
rect = @(t)0<=t & t<=1; % returns logical array (true/false)
t = -1:0.01:2;
plot(t,rect(t));
ylim([-1 2]);

2 件のコメント

AEW
AEW 2022 年 4 月 12 日
Thank you!
Voss
Voss 2022 年 4 月 12 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2021b

質問済み:

AEW
2022 年 4 月 12 日

コメント済み:

2022 年 4 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by