How can i define piecewise function ?

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일

0 개 추천

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)

카테고리

태그

질문:

2014년 2월 22일

답변:

2017년 8월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by