how to define the following function
显示 更早的评论
How to define the following function in MATLAB
f(x) = 1 for 0<= x <= pi
f(x) = 1 for 0<= x <= pi
1 个评论
Walter Roberson
2013-1-21
You seem to have the same entry twice ?
回答(1 个)
Thorsten
2013-1-21
if 0 <= x && x <= pi, y = 0; end
1 个评论
Walter Roberson
2013-1-21
Or, vectorized:
y = zeros(size(x));
y(x >= 0 & x <= pi) = 1;
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!