how to solve piece-wise function?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
f(x)= {1 if x>=0, 0 if x=0, -1 if x<=0
2 Kommentare
Guillaume
am 10 Nov. 2015
Note that your function is ill-defined for x == 0, since it passes all three conditions. You should use strict comparison, < instead of <=.
Antworten (1)
Guillaume
am 10 Nov. 2015
Bearbeitet: Guillaume
am 10 Nov. 2015
I'm not sure what you mean by solve. The roots of that function is obviously just 0.
2 Kommentare
Guillaume
am 10 Nov. 2015
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
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!