Function Handle for a Rectangular Function

2 vues (au cours des 30 derniers jours)
AEW
AEW le 12 Avr 2022
Commenté : Voss le 12 Avr 2022
Would it be possible to create a function handle for a rectangular function defined as follows?
Thanks.

Réponse acceptée

Voss
Voss le 12 Avr 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 commentaires
AEW
AEW le 12 Avr 2022
Thank you!
Voss
Voss le 12 Avr 2022
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by