简体   繁体   中英

Error in solving symbolic inequalities using Matlab

I am new to Matlab. I am trying to use solve :

syms x y
S = solve(x^2 + y^2 + x*y < 1, x > 0, y > 0, [x, y]);

solx = S.x
soly = S.y

but Matlab returns:


Warning: 5 equations in 2 variables.

In C:\\Program
Files\\MATLAB\\R2012a\\toolbox\\symbolic\\symbolic\\symengine.p>symengine at 54

In mupadengine.mupadengine>mupadengine.evalin at 97

In mupadengine.mupadengine>mupadengine.feval at 150

In solve at 160

Warning: Explicit solution could not be found. > In solve at 169

Comma separated list expansion has cell syntax for an array that is not a cell.

Error in sym/subsref (line 1575)

[inds{k},refs{k}] = privformat(inds{k});


Could anyone tell me how to fix this error?

The first thing to do, if possible, is use a newer version of Matlab. The Symbolic Math toolbox has seen a lot of updates in recent years.

I'm using R2015a so I can't test your case exactly. Here are a few things you can try, however. First, use assumptions (link to R2012a archived documentation). Second, I think your error is caused by solving for the vector [xy] , rather than the distinct variables, x and y . When using an old version of Matlab make sure to look at the archived online documentation for your version or use help and doc in your Command Window (what Google shows you will be for the current version only): the archived documentation for solve in R2012a .

Here are those changes applied to your example:

syms x y;
assume(x > 0);
assume(y > 0);
S = solve(x^2 + y^2 + x*y < 1, x, y)

This still returns warnings:

Warning: The solutions are parameterized by the symbols: u, v. To include parameters and conditions in the solution, specify the 'ReturnConditions' option.
> In solve>warnIfParams (line 510)
In solve (line 360)
Warning: The solutions are valid under the following conditions: 4*v^2 < u & u < 4 & 0 < v. To include parameters and conditions in the solution, specify the 'ReturnConditions' option.
> In solve>warnIfParams (line 517)
In solve (line 360)

S = 

    x: [1x1 sym]
    y: [1x1 sym]

but also yields

(- 3*v^2 + u)^(1/2)/2 - v/2

for Sx and v for Sy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM