How a function of Simulink can access the variables of m.file?

11 ビュー (過去 30 日間)
ALI
ALI 2023 年 11 月 9 日
コメント済み: ALI 2023 年 11 月 20 日
Hello,
I need to revise the codes in order to access all variables of mfile in the function of simulink and simulink.
I attached 2 files in this regards,
I appreciate if you can halp.
Thanks

回答 (1 件)

Mann Baidi
Mann Baidi 2023 年 11 月 9 日
編集済み: Mann Baidi 2023 年 11 月 9 日
Hi ALI,
I understand you would like to access the base workspace variables in the Simulink function. For this, you will have to perform some additional work. Here is a list of options to do so:
  1. Use constant blocks to import the base workspace variables elsewhere in your model and pass them into the MATLAB function block as input arguments. This requires no modification of the variable scope, but increases the number of blocks in your model.
  2. Set the variable's scope to 'Parameter' and pass them in as function arguments to the MATLAB function block. To do this, add the base workspace variables that you wish to use in the MATLAB function block to the list of function arguments. Then, set the scope of these variables to 'Parameter' as described here:https://www.mathworks.com/help/simulink/ug/parameter-arguments-in-matlab-function-block-functions.html
These are the most efficient and feasible options you can use to resolve your query
Hope this will help!
  1 件のコメント
ALI
ALI 2023 年 11 月 20 日
Dear,
I defined base workspace variables as Parameters in Simulink Function, and it is working.
Thanks

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

カテゴリ

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