how to define the following function
Show older comments
How to define the following function in MATLAB
f(x) = 1 for 0<= x <= pi
f(x) = 1 for 0<= x <= pi
1 Comment
Walter Roberson
on 21 Jan 2013
You seem to have the same entry twice ?
Answers (1)
Thorsten
on 21 Jan 2013
if 0 <= x && x <= pi, y = 0; end
1 Comment
Walter Roberson
on 21 Jan 2013
Or, vectorized:
y = zeros(size(x));
y(x >= 0 & x <= pi) = 1;
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!