Various functions depending on X
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I wanted to create a function that consists of a number and functions and works like this
if x<-1 y=-x^2-4*x-2
if |x|<1 y=|x|
if x>1 y=2-e^(sqrt(x-1))
0 Commenti
Risposte (1)
John D'Errico
il 18 Nov 2022
If the function is symbolic, then use piecewise.
help piecewise
Note that your function lacks definition, since you do not say what happens when x==1 or x==-1.
For a general matlab function, you can use my piecewise_eval, it is on the file exchange.
Pretty old now, but it should still work.
I also see many other tools on the FEX that claim to do the job too.
0 Commenti
Vedere anche
Categorie
Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!