Can I save my created m-function in Simulink in the library?

12 ビュー (過去 30 日間)
Michael Berner
Michael Berner 2017 年 1 月 13 日
回答済み: Jyotish Robin 2017 年 1 月 19 日
Hello there,
I wrote a couple of functions in Matlab and executed the as m-functions in Simulink. I need them quite often in different projects too. I would prefer to save them into the library and load them as the 'normal' block elements. Is that somehow possible?
Thanks in advance, Michael

採用された回答

Jyotish Robin
Jyotish Robin 2017 年 1 月 19 日
I would suggest you to create a custom block and it to the Simulink Library Browser. This way, you can extend the built-in modeling functionality provided by Simulink. Since you have an existing MATLAB function that models the custom functionality, you can create a custom block using a MATLAB Function block, Fcn block, or Interpreted MATLAB Function block.
  • Use the MATLAB function block if you intend to generate code from your model. This block does have restrictions, the entire gamut of built-in MATLAB functions is not available.
  • Use the Interpreted MATLAB function block if you don't care about code generation, this block can make use of any functions.
  • Use the "Fcn" block if your m-file is trivial and contains a simple expression operating on the inputs. In this case you can type the expression directly into the block dialog and reference the input / output signals as shown in the documentation.
In short, we can create a library having MATLAB function blocks (or one from the other two options) in which you have written the MATLAB functions.
The following link is worth looking:
Hope it helps!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Model Editing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by