フィルターのクリア

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 Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by