Syntax error in a Simulink Fcn block

1 回表示 (過去 30 日間)
Nancy
Nancy 2014 年 8 月 6 日
コメント済み: Yu Jiang 2014 年 8 月 8 日
I am getting a syntax error message for the expression "FiringOrder(u)" (no quotes) in a Fcn block. "FiringOrder" is a 1 x 6 row vector in the base workspace. (I have also tried it with "FiringOrder" defined as a row vector in the model workspace, with the same result--syntax error.) The input is a single value that I'm trying to use to index into the array, outputting the value at the "u'th" column in the row vector.
The help documentation for the Fcn block says that Simulink searches for function names in the expression, and then looks in the MATLAB base workspace, so it should be finding the row vector FiringOrder. I've tried adding the vector as a parameter in the model workspace, and that doesn't work either. This expression is so simple that I can't believe I'm getting a syntax error, but I am. What am I doing wrong??
Thanks.
  2 件のコメント
Yu Jiang
Yu Jiang 2014 年 8 月 6 日
Hi, can you put that block in a Simulink file and post it here?
Nancy
Nancy 2014 年 8 月 7 日
Thanks for the response. Attached is an excerpt from my model that shows the same behavior--a message that there's a syntax error in the Fcn block.
BTW, I'm running R2014a, on a Windows 7 64-bit platform.
If the answer to the problem isn't obvious from the attached, let me know and I'll put in a service request with a zipped copy of the entire project.

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

採用された回答

Yu Jiang
Yu Jiang 2014 年 8 月 7 日
Since FiringOrder is an array in your workspace, it would not be recognized as a function in MATLAB.
To achieve your objective, try replacing the Fcn block with the block "1-D Look up Table" (See Documentation).
Set the Table Data as FiringOrder and the breakpoints as 1:6.
  2 件のコメント
Nancy
Nancy 2014 年 8 月 8 日
Thank you--that works. I see now that the Fcn block would of course be looking for a function (duh!), and that while FiringOrder(u) would be a valid MATLAB expression, Fcn block wouldn't be recognizing all MATLAB expressions, only ones using functions, so it's an syntax error rather than "function not found" since FiringOrder exists but isn't a function. As I said, I was being dense! Thanks again.
Yu Jiang
Yu Jiang 2014 年 8 月 8 日
No problem :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by