Syntax error in simulink

Getting syntax error in Simulink for this expression
m*(u(1)-l*u(3)*u(3)*sin(u(2))+l*u(4)*cos(u(2)))
The equation seems correct. Can anyone explain it?

6 件のコメント

Walter Roberson
Walter Roberson 2016 年 7 月 18 日
We will need more context and the complete error message.
For example that expression would not be valid in a MATLAB Function block because MATLAB Function block need a "function" header.
Quamar Niyaz
Quamar Niyaz 2016 年 7 月 18 日
I tried to put in fcn block parameters window by double clicking the fcn block. I have four function blocks in my model. The expressions in few of them are working, however in few of them, they are not working. For example: (1/M)*(u(1)-u(2)-b*u(3)) worked perfectly.
Image Analyst
Image Analyst 2016 年 7 月 19 日
I think you overlooked where he said "We will need ... the complete error message." That means ALL the red text from the command window.
Walter Roberson
Walter Roberson 2016 年 7 月 19 日
When I copy and paste your code into a Fcn block or Interpreted Fcn block in R2016a, I am not told of any error.
Quamar Niyaz
Quamar Niyaz 2016 年 7 月 20 日
編集済み: Quamar Niyaz 2016 年 7 月 20 日
I am trying to implement this example http://ctms.engin.umich.edu/CTMS/index.php?example=InvertedPendulum&section=SimulinkModeling. I have followed the procedure as specified in it, but getting the errors in the third function block which is as follows:
The expression: m*(u(1)-l*((u(3))^2)*sin(u(2))+l*u(4)*cos(u(2)))
in 'Sim_Exp7/Subsystem/Subsystem/N' has a syntax error
I have also attached my mdl and error files. My Matlab version is R2015b.
Shoanaliy Arul
Shoanaliy Arul 2020 年 11 月 12 日
I am also getting the simular error.
Mine says:
The expression: m*(u(1) - l*u(3)*u(3)*sin(u(2)) + l*u(4)*cos(u(2))) in 'Pend_Model/Subsystem/N' has a syntax error

サインインしてコメントする。

回答 (2 件)

Mark McBroom
Mark McBroom 2020 年 11 月 14 日

0 投票

The following variables need to be defined in the MATLAB workspace:
I, g, b, m, l, M
thetadot is missing a paren. It hsould be:
1/I*(-u(1)*cos(u(3)) - u(2)*sin(u(3)))

1 件のコメント

Mark McBroom
Mark McBroom 2020 年 11 月 14 日
Note. I debugged this by cutting and pasting each of the equations into the MATLAB workspace. This gives more detailed info on undefined variables and syntax errors.

サインインしてコメントする。

Diki
Diki 2024 年 9 月 14 日

0 投票

Error:The expression: (-1/(J/(R^2)+m))*(m*g*sin(u(3))-m*u(1)*(u(4)^2)
in 'RootLocus/Ball and Steam/Fcn'
has a syntax error

カテゴリ

ヘルプ センター および File ExchangeGeneral Applications についてさらに検索

製品

リリース

R2015b

質問済み:

2016 年 7 月 18 日

回答済み:

2024 年 9 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by