Syntax error , Component: Simulink, Category: Block error

18 views (last 30 days)
I am trying to create user defined function theta_2dot of inverted pedulum (cart and pole) using following formulas which is giving me syntax error
Formulas are : -(l*m*cos(u(3))*sin(u(3))*u(4)^2 + F*cos(u(3)) - g*m*sin(u(3)) - M*g*sin(u(3)))/(l*(M + m - m*cos(u(3))^2))
I would like to know correct format for above formulas.
Thank you, Aaron

Answers (1)

Walter Roberson
Walter Roberson on 25 Aug 2024
Edited: Walter Roberson on 25 Aug 2024
Are you trying to use an Interpreted MATLAB Function block ? I think the formula is too complex for an Interpreted MATLAB block, and should be converted to a MATLAB Function block, or modeled with a whole series of Math blocks.
For one thing, I don't think Interpret MATLAB Function block recognizes variables (other than u). It just might possibly recognize variables that have been assigned in the base workspace... I'm not sure.
Note that these days, Interpreted MATLAB Function blocks are recommended against, and will be removed from some later MATLAB release (probably R2025a)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!