Azzera filtri
Azzera filtri

How can i define piecewise function ?

1 visualizzazione (ultimi 30 giorni)
Fatih
Fatih il 22 Feb 2014
Risposto: Andreas Sorgatz il 25 Ago 2017
I want to define a piecewise function
syms x y piecewise([x<=y,1+y],[x>y,1+x])
but i get error message
Undefined function 'piecewise' for input arguments of type 'sym'.
How can i define this function ?

Risposte (1)

Andreas Sorgatz
Andreas Sorgatz il 25 Ago 2017
You are mixing MATLAB and MuPAD syntax. Also ';' or a linefeed is missing. Try
>> syms x y
>> piecewise(x<=y,1+y, x>y,1+x)
ans =
piecewise(x <= y, y + 1, y < x, x + 1)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by