How to define function

조회 수: 3 (최근 30일)
Viktoriia Buliuk
Viktoriia Buliuk 2020년 8월 11일
댓글: Viktoriia Buliuk 2020년 9월 4일
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에서 Operators and Elementary Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by