简体   繁体   English

使用Matlab解决符号不等式时出错

[英]Error in solving symbolic inequalities using Matlab

I am new to Matlab. 我是Matlab的新手。 I am trying to use solve : 我正在尝试使用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: 但是Matlab返回:


Warning: 5 equations in 2 variables. 警告:2个变量中的5个方程式。

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

In mupadengine.mupadengine>mupadengine.evalin at 97 在mupadengine.mupadengine> mupadengine.evalin中,位于97

In mupadengine.mupadengine>mupadengine.feval at 150 在mupadengine.mupadengine> mupadengine.feval中,位于150

In solve at 160 在160解

Warning: Explicit solution could not be found. 警告:找不到明确的解决方案。 > In solve at 169 >在169中解决

Comma separated list expansion has cell syntax for an array that is not a cell. 逗号分隔的列表扩展具有非单元格数组的单元格语法。

Error in sym/subsref (line 1575) sym / subsref中的错误(第1575行)

[inds{k},refs{k}] = privformat(inds{k}); [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. 如果可能的话,第一件事就是使用更新版本的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. 我正在使用R2015a,所以无法完全测试您的情况。 Here are a few things you can try, however. 不过,您可以尝试以下几种方法。 First, use assumptions (link to R2012a archived documentation). 首先,使用assumptions (链接到R2012a存档文档)。 Second, I think your error is caused by solving for the vector [xy] , rather than the distinct variables, x and y . 其次,我认为您的错误是由求解向量[xy] ,而不是由变量xy 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 . 使用旧版本的Matlab时,请确保查看适用于您版本的在线文档,或在“命令窗口”中使用helpdoc (Google只会显示当前版本的信息): R2012a中用于solve的存档文档

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. 警告:解决方案通过以下符号进行参数化:u,v。要在解决方案中包括参数和条件,请指定“ ReturnConditions”选项。
> In solve>warnIfParams (line 510) > 解决中> warnIfParams (第510行)
In solve (line 360) 正在解决 (第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. 警告:解决方案在以下条件下有效:4 * v ^ 2 <u&u <4&0 <v。要在解决方案中包括参数和条件,请指定“ ReturnConditions”选项。
> In solve>warnIfParams (line 517) >在求解中> warnIfParams (第517行)
In solve (line 360) 正在解决 (第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 对于Sxv对于Sy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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