Function Handle for a Rectangular Function

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

 Respuesta aceptada

Voss
Voss el 12 de Abr. de 2022
% 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 comentarios

AEW
AEW el 12 de Abr. de 2022
Thank you!
Voss
Voss el 12 de Abr. de 2022
You're welcome!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2021b

Preguntada:

AEW
el 12 de Abr. de 2022

Comentada:

el 12 de Abr. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by