Effacer les filtres
Effacer les filtres

Subs returns empty sym n-by-0

4 vues (au cours des 30 derniers jours)
Gene McLay
Gene McLay le 23 Sep 2023
Commenté : Gene McLay le 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.

Réponses (1)

Walter Roberson
Walter Roberson le 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 commentaire
Gene McLay
Gene McLay le 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!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by