how to define the following function
Afficher commentaires plus anciens
How to define the following function in MATLAB
f(x) = 1 for 0<= x <= pi
f(x) = 1 for 0<= x <= pi
1 commentaire
Walter Roberson
le 21 Jan 2013
You seem to have the same entry twice ?
Réponses (1)
Thorsten
le 21 Jan 2013
if 0 <= x && x <= pi, y = 0; end
1 commentaire
Walter Roberson
le 21 Jan 2013
Or, vectorized:
y = zeros(size(x));
y(x >= 0 & x <= pi) = 1;
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!