Posts

Showing posts with the label piecewise

How to set a function that can return different value for different range in MatLab? - piecewise -- MatLab

 How to set a function that can return different value for different range in MatLab? - piecewise -- MatLab [Ans] piecewise command [Description] I think explanations of matlab help doc are I think I can not use greater way to describe --- help for sym/piecewise  --- piecewise  Conditionally defined symbolic object PW = piecewise (CONDITION1, VAL1, CONDITION2, VAL2, ..., <OTHERWISEVAL>) Create a conditionally defined symbolic object. It equals the k-th value if the k-th condition holds and the first k-1 conditions are false. If all conditions are false, it equals otherwiseVal. The final argument otherwiseVal may be omitted; it defaults to sym(NaN). In contrast to an if statement, the truth value of the conditions need not be decidable at the time the conditional object is defined. [Syntax] pw = piecewise(cond1,val1,cond2,val2,...,<otherwiseVal>) Type of <otherval> must be constant. If <otherVal> was not given...