How to write and plot multi-variable piecewise function? (Symbolic Toolbox)
조회 수: 1 (최근 30일)
이전 댓글 표시
I want to write and plot a two-variable piecewise function, f(y1,y2). I have had success plotting a one-variable piecewise function using fplot, and success plotting a normal two-variable function using fsurf.
I now want to use fsurf to plot a piecewise function, but the syntax doesn't appear to work. The original script is below, where apart from y1 and y2, everything else is a constant ie. actual number:
syms y1 y2
g(y1,y2) = Fij(3)*(DTC1i-DTC1o+DT1-DT2) + Fij(4)*(DTC2i-((Tp-DTmin)-y2)+DT1-DT2) - Fij(1)*(DTH1o-DTH1i-DT3+DT4) - Fij(2)*((Tp-y1)-DTH2i-DT3+DT4)
fsurf(g)
The issue is that I have different conditions for y1 and y2. My conditions are that:
If (Tp-DTmin)-y2) < 0, the whole term is zero. Otherwise, it remains untouched.
If (Tp-y1) < 0, the whole term is zero. Otherwise, it remains untouched.
Normally I would use the piecewise syntax of:
g(y1) = (cond,var,cond,var)
But that only appears to work for 1 variable. How do I use the piecewise notation for conditions of different variables?
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!