How to write piecewise function in symbolic form?
조회 수: 19 (최근 30일)
이전 댓글 표시
I have to make a piecewise function in symbolic form using the following:
-2 <= t <=-1, t+2,
-1 < t <=1, 1,
1<t <=2, -t+2
otherwise 0
i tried the code below but it seems to be giving me errors. Any idea what I'm doing wrong?
syms x(t)
x(t) = piecewise(-2 <=t && t <=-1, t+2,-1 < t && t <=1,1,1<t && t<=2,-t+2 ,0);
fplot (x(t))
댓글 수: 0
답변 (1개)
Paul
2021년 9월 23일
Use &, not &&
syms x(t)
x(t) = piecewise(-2 < t & t <= -1 , t+2, -1 < t & t <= 1, 1, 1 < t & t <= 2, -t+2, 0)
fplot(x(t),'-o')
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!