Can't get level-2 matlab s-function to work

16 ビュー (過去 30 日間)
Akshay Palakkal
Akshay Palakkal 2021 年 1 月 6 日
回答済み: Srija Kethiri 2022 年 6 月 3 日
Hi,
I'm trying to incorporate a Level-2 MATLAB S-Function into my Simulink model, but I keep getting the same error:
Error: Cannot create the S-function file as ' ' because the S-function name is not a valid MATLAB function name.
Component:Simulink | Category:Model error
Things I've already ensured/tried:
  • I've ensured that the function name in the code-body of the function definition matches the saved file name (The function is from a Simulink shipping demo.)
  • The working directory and paths are set correctly.
  • When I hit edit, it opens up the correct "msfcn_times_two.m" file in the working directory. Even though it opens the right file on edit, hitting apply doesn't seem to affect the model. The demo had one input and one output. So I tried changing the number of input and output ports in the code body to see what effect it would have. As suspected, the input and output port numbers stayed one, i.e. no change in model.
  • It is inside a conditionally executed sub-system so I've set the block.SampleTimes paramter to [-1, 0].
  • The error pops up whenever I try to compile or execute the program. [ I'm running the 2020a release. ]
I'm sure I'm making a really silly mistake or overlooking something super basic somewhere, just can't seem to find it. Any help on how to solve this would be much appreciated.

回答 (1 件)

Srija Kethiri
Srija Kethiri 2022 年 6 月 3 日
Hi Akshay,
To resolve the issue, update your MATLAB to R2021a.
If that doesn’t resolve your issue, please send themodel/ a dummy model along with other relevant files (code and data) and precise reproduction steps so I can try and recreate the issue.

カテゴリ

Help Center および File ExchangeModel, Block, and Port Callbacks についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by