I need to helpe to solve this equation x-y=12, 0<x<22, 0<y<100
조회 수: 2 (최근 30일)
이전 댓글 표시
I need to helpe to solve this equation by matlab x-y=12, 0<x<22, 0<y<100
댓글 수: 2
John D'Errico
2020년 5월 20일
There are infinitely many solutions. But why do you "need" to use MATLAB? Just use pencil and paper. Unless, of course, this is homework, and you don't want to admit it.
If x - y = 12, then can you "solve" for x? Be serious. Of course you can.
In that case, what value of x do you find for y == 0, the lower end point for y?
As y increases beyond that point, how large must y be for no solution to exist any longer?
Therefore, what is the complete set of solutions?
Oh, yes, I almost forgot. This is your homework. So make an effort.
채택된 답변
John D'Errico
2020년 5월 20일
편집: John D'Errico
2020년 5월 20일
As I said, there are infinitely many solutions.
As well, it is often the case that the solution set of a system of inequalities is a rather complicated region. For the simple problem you have posed, this seems to work.
syms x y
assume(0 <= x & x <= 22)
assume(0 <= y & y <= 100)
sol = solve(x-y == 12,x,'returnconditions',true);
sol.x
ans =
y + 12
sol.conditions
ans =
y <= 10
댓글 수: 2
John D'Errico
2020년 5월 20일
READ THE HELP FOR SOLVE.
As I said, there are infinitely many solutions to your problem. An inequailty has that property. It describes a set, thus merely reduces the set of possible solutions. For example, if I pose the simple inequality:
X > 0
That reduces the problem to the positive half of the real line. In general, the solution to an inequality or set of them is an infinite set of points. For a real variable, that would be some portion of the real line. (Things can get far more complicated when the problem has multiple variables or is nonlinear in some way.)
But suppose we do not use that property? What does solve do?
syms x y
assume(0 <= x & x <= 22)
assume(0 <= y & y <= 100)
sol = solve(x-y == 12,x)
Warning: Solutions are valid under the following conditions: y <= 10. To include parameters and conditions in the solution,
specify the 'ReturnConditions' value as 'true'.
> In solve>warnIfParams (line 482)
In solve (line 357)
sol =
y + 12
So solve tells us the "solution" is x = y+12, but then it was forced to issue a warning that the solution provided is only valid under a specific additional condition. And what is that additional condition? y <= 10.
The 'returnconditions' property removed the warning message, then putting the necessary condition into the field sol.conditions.
sol = solve(x-y == 12,x,'returnconditions',true)
sol =
struct with fields:
x: [1×1 sym]
parameters: [1×0 sym]
conditions: [1×1 sym]
추가 답변 (1개)
Ameer Hamza
2020년 5월 20일
Following works with symbolic toolbox
syms x y
sol = solve([x-y==12, 0<x<22, 0<y<100])
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!