Subs returns empty sym n-by-0

4 次查看(过去 30 天)
Gene McLay
Gene McLay 2023-9-23
评论: Gene McLay 2023-9-23
I've been working on some matlab programs to help me solve a large set of linear equations as part of a structural analysis project, and for some reason, when I try and substitute the solution struct from the first solve into my next set of equations using subs(expr,sol), it returns "Empty sym: 3-by-0", when it should be a 3-by-10 sym. I've tried it on a bunch of other symbolic expressions containing the same variables, but they all return an empty sym.
The solve is working correctly, as it is spitting out unique solutions for everything. It's just the subs that's not working.
I also have a very similar script, in which it is still working. I've attached both in case it's a script-specific issue. The folder labelled "S1.1" is the one that works, and "S2.1" is the one with issues. In each folder "elastic_analysis" is the script in question, but I've included the necessary helper functions as well to run the code. The offending line is on line 260 of S1.2.

回答(1 个)

Walter Roberson
Walter Roberson 2023-9-23
subs(expr,sol)

If sol is a struct output of solve() with returnparameters but there were no auxiliary variables introduced then the parameters field of the struct will exist but be empty.

If you subs() a struct in the second parameter and any field of the struct is empty, then the result is empty.

It would be better if subs() knew to ignore empty parameters field but it doesn't, so you might need to rmfield before the subs()

  1 个评论
Gene McLay
Gene McLay 2023-9-23
I see! Well given that I'm finding a unique solution, I can just drop the parameters in the solve.
Thanks Walter!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by