Azzera filtri
Azzera filtri

Simulink import matrix directly to matlab function block

9 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Rick Rosson
Rick Rosson il 2 Dic 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 Commenti
Andrea Giambone
Andrea Giambone il 6 Mag 2020
The 'parameter' solution works for me, thanks a lot!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Simulink Functions in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by