How to write and plot multi-variable piecewise function? (Symbolic Toolbox)

2 ビュー (過去 30 日間)
Rahul Prasher
Rahul Prasher 2018 年 3 月 31 日
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 件)

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by