フィルターのクリア

Simulink import matrix directly to matlab function block

8 ビュー (過去 30 日間)
alp
alp 2011 年 12 月 2 日
コメント済み: Andrea Giambone 2020 年 5 月 6 日
I am trying to import a matrix from matlab workspace directly to a matlab function without specifying it as a input port. I only want to import the matrix into function, change its values and thats all. I don't want it to be a signal. Can I do that and if so how?

採用された回答

Rick Rosson
Rick Rosson 2011 年 12 月 2 日
There are two possibilities that I can think of:
  1. Parameter
  2. Data Store Memory
Parameter
You can specify the matrix as a parameter of the function rather than as an input to the function.
I am not 100 percent sure that this will work as you intend, but please try the following:
  1. Double-click on the MATLAB Function Block to open the MATLAB Function Block Editor window.
  2. Specify a variable in the list of input arguments to represent the matrix. The name of this variable should be the same as the name of the variable defined in the MATLAB Workspace. I will assume this variable is called A.
  3. At the top of the window is a toolbar. Find the "Edit Data/Ports" tool, and click on it to bring up the Ports and Data Manager.
  4. Find the variable A in the list of arguments in the left pane of the dialog box.
  5. The "Scope" of this variable should be listed as "Input".
  6. Change the "Scope" of A from "Input" to "Parameter".
  7. Close the Ports and Data Manager.
  8. Close the MATLAB Function Block Editor.
  9. Save the model.
Data Store Memory
If that does not work for your use case, then you can try to define the matrix as a Data Store Memory (DSM) in Simulink, and access it from the MATLAB Function block as a global variable.
HTH.
Rick
  4 件のコメント
Mohamed Elfatih
Mohamed Elfatih 2017 年 10 月 29 日
Thanks it worked for me :)
Andrea Giambone
Andrea Giambone 2020 年 5 月 6 日
The 'parameter' solution works for me, thanks a lot!

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

その他の回答 (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