Filter löschen
Filter löschen

Simulink import matrix directly to matlab function block

9 Ansichten (letzte 30 Tage)
alp
alp am 2 Dez. 2011
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?

Akzeptierte Antwort

Rick Rosson
Rick Rosson am 2 Dez. 2011
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 Kommentare
Mohamed Elfatih
Mohamed Elfatih am 29 Okt. 2017
Thanks it worked for me :)
Andrea Giambone
Andrea Giambone am 6 Mai 2020
The 'parameter' solution works for me, thanks a lot!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by