MATLAB:为什么solve返回一个空的sym对象?

发布于 2024-08-02 13:44:58 字数 1228 浏览 5 评论 0原文

我试图在 MATLAB 中求解这组方程,但得到一个空的 sym 对象:

equations = {'I2B+I2EQAB=I22B+I2EQBC',...
             'I2A=I2EQAB+I2EQAC+I22A',...
             'I2C+I2EQBC+I2EQAC=I22C',...
             'I22B=IZB+IC1B',...
             'IZB=IC2B+IZBB',...
             'I22C=-I2C*Z2C*YC/2+IZC',...
             'IZC=IC2C+IZCC',...
             'I22A=IC1A+IZA1',...
             'IC4A+IZA2=IZBB+IZCC',...
             'IZB*Z2LB+IC2B*2/YB=IC1B*2/YB',...
             'I2C*Z2C=-IC2C*2/YC+IZC*Z2LC',...
             'IZA1*m*Z2LA+IC2A*2/(m*YA)=IC1A*2/(m*YA)',...
             'IC4A*2/((1-m)*YA)=IC2A*2/(m*YA)+IZA2*(1-m)*Z2LA',...
             'I2EQBC*Z2EQBC+IZC*Z2LC=IZB*Z2LB',...
             'I2B*Z2B+IC1B*2/YB',...
             'I2C*Z2C+IC1C*2/YC',...
             'I2A*Z2A+IC1A*2/(m*YA)',...
             'IZB*Z2LB+(1-m)*Z2LA*IZA2=IZA1*m*ZL2A-I2EQAB*Z2EQAB',...
             'IZA1*m*Z2LA=IZA2*(1-m)*Z2LA+IZC*Z2LC+I2EQAC*Z2EQAC',...
             'IC4A/((1-m)*YA)=IC2C/YC'};
variables = {'m','I2A','I2B','I2C','I2EQAB','I2EQAC','I2EQBC',...
             'IZA1','IC1A','IC2A','IZA2','IC4A','IC1B','IZB',...
             'IC2B','IZBB','IZC','IC2C','IZCC'};
LL = solve(equations{:},variables{:})

你能帮我找出问题所在吗?

I´m trying to solve this set of equations in MATLAB and I get an empty sym object:

equations = {'I2B+I2EQAB=I22B+I2EQBC',...
             'I2A=I2EQAB+I2EQAC+I22A',...
             'I2C+I2EQBC+I2EQAC=I22C',...
             'I22B=IZB+IC1B',...
             'IZB=IC2B+IZBB',...
             'I22C=-I2C*Z2C*YC/2+IZC',...
             'IZC=IC2C+IZCC',...
             'I22A=IC1A+IZA1',...
             'IC4A+IZA2=IZBB+IZCC',...
             'IZB*Z2LB+IC2B*2/YB=IC1B*2/YB',...
             'I2C*Z2C=-IC2C*2/YC+IZC*Z2LC',...
             'IZA1*m*Z2LA+IC2A*2/(m*YA)=IC1A*2/(m*YA)',...
             'IC4A*2/((1-m)*YA)=IC2A*2/(m*YA)+IZA2*(1-m)*Z2LA',...
             'I2EQBC*Z2EQBC+IZC*Z2LC=IZB*Z2LB',...
             'I2B*Z2B+IC1B*2/YB',...
             'I2C*Z2C+IC1C*2/YC',...
             'I2A*Z2A+IC1A*2/(m*YA)',...
             'IZB*Z2LB+(1-m)*Z2LA*IZA2=IZA1*m*ZL2A-I2EQAB*Z2EQAB',...
             'IZA1*m*Z2LA=IZA2*(1-m)*Z2LA+IZC*Z2LC+I2EQAC*Z2EQAC',...
             'IC4A/((1-m)*YA)=IC2C/YC'};
variables = {'m','I2A','I2B','I2C','I2EQAB','I2EQAC','I2EQBC',...
             'IZA1','IC1A','IC2A','IZA2','IC4A','IC1B','IZB',...
             'IC2B','IZBB','IZC','IC2C','IZCC'};
LL = solve(equations{:},variables{:})

Can you help me figure out what's going wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

李不 2024-08-09 13:44:58
Warning: 20 equations in 19 variables. 
> In solve at 139
Warning: Explicit solution could not be found. 
> In solve at 170

LL =

[ empty sym ]

我认为这是不言自明的,如果不查看与 相关的文档DSOLVE 其中:

诊断如果 dsolve 找不到
方程的解析解,它
打印警告:警告:显式
无法找到解决方案。和
返回一个空的 sym 对象。

Warning: 20 equations in 19 variables. 
> In solve at 139
Warning: Explicit solution could not be found. 
> In solve at 170

LL =

[ empty sym ]

I think that's self explanatory, if not check out the documentation related to DSOLVE where:

Diagnostics If dsolve cannot find an
analytic solution for an equation, it
prints the warning: Warning: Explicit
solution could not be found. and
returns an empty sym object.

梓梦 2024-08-09 13:44:58

solve() 有大写字母变量名的问题,就像你的一样。

请参阅http://www.mathworks.com/matlabcentral/newsreader/view_thread/303201< /a>

solve() has issues with variable names in capital letters, as yours.

Please refer to http://www.mathworks.com/matlabcentral/newsreader/view_thread/303201

你的往事 2024-08-09 13:44:58

我尝试重新格式化方程并直接输入到符号工具箱中,而求解函数只是吐出所有方程,因此它无法按照当前方程求解这些变量。

您是否了解所有这些变量的域或约束?如果您这样做,我会考虑指定所有这些,也许它会让求解器为您找到解决方案。

为了让您快速启动并运行符号工具箱,这里是重新格式化的方程以适应:

equations := {
    I2B + I2EQAB                          = I22B + I2EQBC,
    I2A                                   = I2EQAB + I2EQAC + I22A,
    I2C + I2EQBC + I2EQAC                 = I22C,
    I22B                                  = IZB + IC1B,
    IZB                                   = IC2B + IZBB,
    I22C                                  = -I2C * Z2C * YC / 2 + IZC,
    IZC                                   = IC2C + IZCC,
    I22A                                  = IC1A + IZA1,
    IC4A + IZA2                           = IZBB + IZCC,
    IZB * Z2LB + IC2B * 2 / YB            = IC1B * 2 / YB,
    I2C * Z2C                             = -IC2C * 2 / YC + IZC * Z2LC,
    IZA1 * m * Z2LA + IC2A * 2 / (m * YA) = IC1A * 2 / (m * YA),
    IC4A * 2 / ((1 - m) * YA)             = IC2A * 2 / (m * YA) + IZA2 * (1 - m) * Z2LA,
    I2EQBC * Z2EQBC + IZC * Z2LC          = IZB * Z2LB,
    I2B * Z2B + IC1B * 2 / YB,
    I2C * Z2C + IC1C * 2 / YC,
    I2A * Z2A + IC1A * 2 / (m * YA),
    IZB * Z2LB + (1 - m) * Z2LA * IZA2    = IZA1 * m * ZL2A - I2EQAB * Z2EQAB,
    IZA1 * m * Z2LA                       = IZA2 * (1 - m) * Z2LA + IZC * Z2LC + I2EQAC * Z2EQAC,
    IC4A / ((1 - m) * YA)                 = IC2C / YC
}:

variables := {
    m, I2A, I2B, I2C, I2EQAB, I2EQAC ,I2EQBC,
    IZA1, IC1A, IC2A, IZA2, IC4A, IC1B, IZB,
    IC2B, IZBB, IZC, IC2C, IZCC
}:

solve(equations, variables)

要指定所有已知变量都是实数,请使用以下命令:

assume(variables, Type::Real)

另请注意,我计算了 36 个唯一变量(除非我犯了错误)如果求解器能够产生结果,您将获得这些方程的大量“假设”列表。我会看看你的方程,看看你是否可以将它们分组并在较小的集合中求解它们。

I tried reformatting the equations and inputting directly into the symbolic toolbox, and the solve function just spits out all the equations, so it cannot solve for those variables as the current equations stand.

Do you have any knowledge about the domains or constraints for all those variables? If you do I'd look at specifying all those, perhaps it would allow the solver to find a solution for you.

To get you quickly up and running in the symbolic toolbox, here's your equations reformatted to fit:

equations := {
    I2B + I2EQAB                          = I22B + I2EQBC,
    I2A                                   = I2EQAB + I2EQAC + I22A,
    I2C + I2EQBC + I2EQAC                 = I22C,
    I22B                                  = IZB + IC1B,
    IZB                                   = IC2B + IZBB,
    I22C                                  = -I2C * Z2C * YC / 2 + IZC,
    IZC                                   = IC2C + IZCC,
    I22A                                  = IC1A + IZA1,
    IC4A + IZA2                           = IZBB + IZCC,
    IZB * Z2LB + IC2B * 2 / YB            = IC1B * 2 / YB,
    I2C * Z2C                             = -IC2C * 2 / YC + IZC * Z2LC,
    IZA1 * m * Z2LA + IC2A * 2 / (m * YA) = IC1A * 2 / (m * YA),
    IC4A * 2 / ((1 - m) * YA)             = IC2A * 2 / (m * YA) + IZA2 * (1 - m) * Z2LA,
    I2EQBC * Z2EQBC + IZC * Z2LC          = IZB * Z2LB,
    I2B * Z2B + IC1B * 2 / YB,
    I2C * Z2C + IC1C * 2 / YC,
    I2A * Z2A + IC1A * 2 / (m * YA),
    IZB * Z2LB + (1 - m) * Z2LA * IZA2    = IZA1 * m * ZL2A - I2EQAB * Z2EQAB,
    IZA1 * m * Z2LA                       = IZA2 * (1 - m) * Z2LA + IZC * Z2LC + I2EQAC * Z2EQAC,
    IC4A / ((1 - m) * YA)                 = IC2C / YC
}:

variables := {
    m, I2A, I2B, I2C, I2EQAB, I2EQAC ,I2EQBC,
    IZA1, IC1A, IC2A, IZA2, IC4A, IC1B, IZB,
    IC2B, IZBB, IZC, IC2C, IZCC
}:

solve(equations, variables)

To specify that all your known variables are real numbers, use this command:

assume(variables, Type::Real)

Also note that I count 36 unique variables (unless I made a mistake) in the equations, you'd be getting a huge list of "what-if's" for those equations if the solver was able to produce a result. I'd look at your equations and see if you could group them out and solve them in smaller sets.

盗梦空间 2024-08-09 13:44:58

Matlab,符号求解:solve()

我认为名称超过一个字符的符号变量存在问题。

az 有效,但每当我尝试用两个或更多字母解决问题时,它就会吐出
返回空集。

例如,像solve('xy*10 = 1', 'xy') 这样简单的方法不起作用:(

Matlab, symbolic solve: solve()

I think has issues with symbolic variables who's names are more than one character.

a-z works, but anytime i try to solve something with two letters or more it just spits
back out the empty set.

For instance, something as simple as solve('xy*10 = 1', 'xy') doesn't work :(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文