필터 지우기
필터 지우기

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