just i want to know how we solve this system:
x+y = 1
max(x,y)=2
i tried this code but an error always appear:
syms x y
solve(x+y ==1,max(x,y)==2)
//Error using sym/max (line 97)
Input arguments must be convertible to floating-point numbers
any help ?

4 件のコメント

Rik
Rik 2018 年 3 月 9 日
max(x,y) can be rewritten to (x>y)*x+(x<=y)*y
syms x y
solve([x+y ==1,(x>y)*x+(x<=y)*y ==2])
But alas, this doesn't work either:
Error using mupadengine/feval (line 187)
System contains an equation of an unknown type.
Fatima Hammoud
Fatima Hammoud 2018 年 3 月 9 日
thanks for your try, i appreciate that
Rik
Rik 2018 年 3 月 9 日
Substituting the solutions, it indeed solves it, so you can add it as the answer, Torsten.
Fatima Hammoud
Fatima Hammoud 2018 年 3 月 9 日
Rik , can you explain to me more ? did you find the solution ?

サインインしてコメントする。

 採用された回答

Torsten
Torsten 2018 年 3 月 9 日
編集済み: Torsten 2018 年 3 月 9 日

0 投票

syms x y
[solx, soly] = solve([x+y==1,piecewise(x>y,x,y)==2],[x y])
Best wishes
Torsten.

3 件のコメント

Fatima Hammoud
Fatima Hammoud 2018 年 3 月 9 日
Thank you sir for your help, but 'piecewise' is Undefined function or variable in Matlab , are you using MuPAD?
Torsten
Torsten 2018 年 3 月 9 日
Maybe you use an older MATLAB version ?
https://de.mathworks.com/help/symbolic/piecewise.html
Best wishes
Torsten.
Fatima Hammoud
Fatima Hammoud 2018 年 3 月 9 日
That's weird i'm using R2016a !!
Any way, thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by