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!
  3 个评论
Viktoriia Buliuk
Viktoriia Buliuk 2020-8-11
I try to define Window function. I have tried with if.
KSSV
KSSV 2020-8-11
Show us your code.

请先登录,再进行评论。

采纳的回答

hosein Javan
hosein Javan 2020-8-11
function y = f(x)
y = zeros(size(x));
y(abs(x) < 1) = 1;
end
  5 个评论
hosein Javan
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.
Viktoriia Buliuk
Viktoriia Buliuk 2020-9-4
Thank you very much!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by