How to define function
4 次查看(过去 30 天)
显示 更早的评论
Hello!
Could you, please, suggest an answer:
How to define function f (x), which for x from -1 to 1, f (x) = 1; and outside these limits f (x) = 0.
Thank in advance!
采纳的回答
hosein Javan
2020-8-11
function y = f(x)
y = zeros(size(x));
y(abs(x) < 1) = 1;
end
5 个评论
hosein Javan
2020-8-11
ofcourse unless you want to use function file, you need this multiplication only to define your function in anonymous form. correct.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!