How to load a .m-File into a Simulink block 'MATLAB Function'?

28 ビュー (過去 30 日間)
Lukas Bathelt
Lukas Bathelt 2017 年 8 月 18 日
編集済み: Aniruddha Katre 2017 年 8 月 18 日
Hello,
I made a Simulink model and I'm using a MATLAB Function block. In 'Model Properties/Callbacks/InitFcn' there is my .m-File. This file loads all parameters for my model. Only the MATLAB Function block gives me an error message that the parameters which are used in the MATLAB Function block are undefined. I don't want to write all the used parameters in the MATLAB Function block.
Is there a way to solve this problem? Any ideas?
Thank you ;)

回答 (1 件)

Aniruddha Katre
Aniruddha Katre 2017 年 8 月 18 日
編集済み: Aniruddha Katre 2017 年 8 月 18 日
The parameters you load into the MATLAB workspace are not visible in the MATLAB Function block because they are not set as parameters of the block nor are they explicit inputs to the block. You will need to go to the Ports and Data Manager option inside the MATLAB Function block and define the variables you load into the MATLAB workspace as parameters for the block. Instructions for that can be found here:

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by