Using symbolic syms inside a Simulink Function — Error: Symbolic not allowed
Ältere Kommentare anzeigen
Hello everyone,
I am working with MATLAB/Simulink and trying to implement a time-varying LQR (TV-LQR).
At each simulation step, I want to:
- Take the desired state x_desired
- Linearize the nonlinear model around this state to compute matrices A and B
- Compute the LQR gain K
- Apply the control lawu=udesired−K(x−xdesired)u = u_{\text{desired}} - K (x - x_{\text{desired}})u=udesired−K(x−xdesired)
The problem is that Simulink gives an error saying that symbolic variables (syms) are not allowed inside a Simulink Function.
How can I linearize my model at each step without using symbolic variables in Simulink?
Is there a recommended way to do numerical linearization at runtime?
Thanks!
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 25 Nov. 2025
1 Stimme
You cannot mix symbolic variables and Control System Toolbox or Simulink Control Design https://www.mathworks.com/help/slcontrol/ug/linearize.html .
I am not aware of anything in the Symbolic Toolbox that would help to linearize models. (Though it is true that you can do some steps using the laplace transform of transform functions.)
In https://www.mathworks.com/matlabcentral/answers/305339-how-to-create-a-transfer-function-with-gain-k#comment_395202 I discussed the closest that you can get to symbolic variables using Simulink models (it is not very close.)
1 Kommentar
boutegui
am 30 Nov. 2025
Kategorien
Mehr zu State-Space Control Design finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


