Filter löschen
Filter löschen

Subs returns empty sym n-by-0

4 Ansichten (letzte 30 Tage)
Gene McLay
Gene McLay am 23 Sep. 2023
Kommentiert: Gene McLay am 23 Sep. 2023
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.

Antworten (1)

Walter Roberson
Walter Roberson am 23 Sep. 2023
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 Kommentar
Gene McLay
Gene McLay am 23 Sep. 2023
I see! Well given that I'm finding a unique solution, I can just drop the parameters in the solve.
Thanks Walter!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by