필터 지우기
필터 지우기

how to solve piece-wise function?

조회 수: 2 (최근 30일)
rising falcon
rising falcon 2015년 11월 10일
댓글: rising falcon 2015년 11월 13일
f(x)= {1 if x>=0, 0 if x=0, -1 if x<=0
  댓글 수: 2
Guillaume
Guillaume 2015년 11월 10일
Note that your function is ill-defined for x == 0, since it passes all three conditions. You should use strict comparison, < instead of <=.
rising falcon
rising falcon 2015년 11월 13일
thak you

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2015년 11월 10일
편집: Guillaume 2015년 11월 10일
That function has a name, it's the signum function, called sign in matlab.
I'm not sure what you mean by solve. The roots of that function is obviously just 0.
  댓글 수: 2
rising falcon
rising falcon 2015년 11월 10일
how to wirte it in matlab?why we use if and end statement to write it in matlab?
Guillaume
Guillaume 2015년 11월 10일
How to write functions and how to use if statement is covered in the Getting Started tutorial in the doc and in million of other tutorials.
function s = mysignum(x)
if x > 0
s = 1;
elseif x < 0
s = -1;
else
s = 0;
end
end

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by