Filter löschen
Filter löschen

How can i define piecewise function ?

1 Ansicht (letzte 30 Tage)
Fatih
Fatih am 22 Feb. 2014
Beantwortet: Andreas Sorgatz am 25 Aug. 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 ?

Antworten (1)

Andreas Sorgatz
Andreas Sorgatz am 25 Aug. 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)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by