How can i define piecewise function ?

1 次查看(过去 30 天)
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 ?

回答(1 个)

Andreas Sorgatz
Andreas Sorgatz 2017-8-25
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)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by