[Simulink] Call the same Matlab function multiple times in a model

11 vues (au cours des 30 derniers jours)
Clément E.
Clément E. le 4 Juil 2016
Commenté : Walter Roberson le 5 Juil 2016
Hi,
I have a generic Matlab function describing the behaviour of an battery electrode and I would like to call it in my model with various parameters (one call for the positive electrode, and the other call for the negative electrode calculation).
In order to make my function generic, I use a structure that contains parameters of the positive and negative electrode so that calling it with argument "pos" or "neg" will make the calculations with whether positive or negative parameters. Unfortunately, Simulink sees that as a "non constant parameter" and refuses to operate.
Do you have an idea of a way to call my "unique function" twice in my model: one call for the negative electrode and an other call for the positive one?
Thanks!
  1 commentaire
Clément E.
Clément E. le 5 Juil 2016
In other words, I have two sets of parameters (one for the positive electrode and another for the negative electrode), and I want to call a Matlab function with those two sets, without having to copy/duplicate the block.
For this matter, I was using a Data Dictionary containing each parameter as a structure with two fields : pos and neg.
Unfortunately, Simulink won't let you use the syntax "Param.(Electrode)" in a Matlab Function Block.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 4 Juil 2016
Use a Constant Block of signal type Boolean feeding into that parameter ?
Boolean because Simulink does not support signals that are type string.
https://www.mathworks.com/matlabcentral/newsreader/view_thread/45166
  6 commentaires
Clément E.
Clément E. le 5 Juil 2016
Right, this is what I've finally done. But I'm still not very confident with the way I manage my parameters (Data Dictionary and Structures). Is there some Best Practices for using parameters of that kind in a Simulink Model?
Thank you again for your time.
Walter Roberson
Walter Roberson le 5 Juil 2016
Sorry I do not know about that.

Connectez-vous pour commenter.

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by