Make parameters available inside Simulink's Matlab functions
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I'm working on a Simulink diagram where many blocks are implemented as Matlab function blocks. Most of these blocks have a call like
param = get_param();
inside them, as their calculations depend on a number of parameters. I implemented the parameter function as a function instead of a script to be able to call it from the Matlab function blocks. From what I understand, this way of loading parameters means I create a new copy of the parameter struct for each block that has a call to get_param(), for each timestep. Probably very inefficient.
Ideas for how to do it better? Adding the parameter struct as an input singal to each block is possible, but will clutter my diagram. Using evalin() is also possible, but requires the use of global variables.
0 comentarios
Respuestas (1)
Kushagr Gupta
el 17 de Mzo. de 2017
Editada: Kushagr Gupta
el 17 de Mzo. de 2017
I would recommend using Data Store Memory Block for the structure parameter and using it as a global variable within the various MATLAB Function blocks.
In order to understand more about it, go through the following link:
A piece of advice, get_param() is an internal MATLAB function too, hence you should try avoiding using the same name, else your implementation will shadow the inbuilt one which could cause issues later on.
0 comentarios
Ver también
Categorías
Más información sobre Programmatic Model Editing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!