how to solve a linear system with a maximum function
Show older comments
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 Comments
Rik
on 9 Mar 2018
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
on 9 Mar 2018
Rik
on 9 Mar 2018
Substituting the solutions, it indeed solves it, so you can add it as the answer, Torsten.
Fatima Hammoud
on 9 Mar 2018
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!