필터 지우기
필터 지우기

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 CenterFile Exchange에서 Simulink Functions에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by