Help fixing old Lagrange equation solver - updates have stopped "sym" being able to work on expressions but I don't know how to fix.

조회 수: 5 (최근 30일)
Hi, I am trying to get a MatLab example of contorl for an inverted pendulum running, but the project is quite old and seems to have been broken by an update. The code used to solve the Lagrangian no longer functions, and throws the error below when I try and run it:
I have done some searching, and found references to this problem, but no solutions that I could implement. I was wandering if someone could help me get the EulerLagrange function working again in R2022b? Sorry for the fuss I am relatively new to MatLab.
  댓글 수: 3
Dylan
Dylan 2023년 7월 25일
I tried to use str2sym myself, changing the qt = arrayfun(...) line to use that instead. It caused the same issue elsewhere in the code, but not a sym() command in the file but somewhere down in the subs() command. I realize I forgot to attach the files themselves, which I will add here if anyone wants to take a look.
Steven Lord
Steven Lord 2023년 7월 25일
Please show us the full and exact error message that occurs after you made that modification in your sym calls in your code.

댓글을 달려면 로그인하십시오.

답변 (1개)

Cris LaPierre
Cris LaPierre 2023년 7월 25일
Not sure if the answer is correct, but the errors are removed by
  1. using str2sym
  2. changing '[' to '('
(ln 79)> qt = arrayfun(@(ii) symfun(str2sym(['q' int2str(ii) '(t)']),t),1:numcoor,'UniformOutput',false);
(ln 115)> VF = subs(VF,str2sym(['Z(',int2str(indqqd(jj)),')']),str2sym(['Y(',int2str(jj),')']));
(ln 152)> Y = arrayfun(@(ii) str2sym(['Y(' int2str(ii) ')']),1:2*numcoor,'UniformOutput',false);

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by