Effacer les filtres
Effacer les filtres

Simulink import matrix directly to matlab function block

8 vues (au cours des 30 derniers jours)
alp
alp le 2 Déc 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?

Réponse acceptée

Rick Rosson
Rick Rosson le 2 Déc 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 commentaires
Mohamed Elfatih
Mohamed Elfatih le 29 Oct 2017
Thanks it worked for me :)
Andrea Giambone
Andrea Giambone le 6 Mai 2020
The 'parameter' solution works for me, thanks a lot!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by