Unique workspace for each instance of Interpreted MATLAB Function block?
Mostrar comentarios más antiguos
I have a Simulink model with several Interpreted MATLAB Function blocks that all call the same function. Within that function, I load a structure variable from the base workspace that is used in calculating the outputs. Each instance of the block within my model needs to load a different structure variable. I assume there is some overhead in loading these variables from the base workspace every time the function is called, so I'd prefer to just load them once when the simulation is initialized and save them within the function workspace as persistent variables. However, that doesn't seem possible because the function workspace is common among all the blocks that call this function. Is there any way to have each instace of the block call the same function but with a different workspace? Or are there other efficient ways to load base workspace variables into the Interpreted MATLAB Function block? Thanks!
4 comentarios
Paul
el 18 de En. de 2022
Do you already have an implementation that works and you're just trying to improve it?
If so, how does each instance of the function called in the Interpreted Matlab Function know which structture to load? And where is each structure loaded from and how are they loaded into the function?
Herschel Pangborn
el 18 de En. de 2022
Editada: Herschel Pangborn
el 18 de En. de 2022
Paul
el 18 de En. de 2022
Exactly how is a structure, or actually class object instances, loaded from the base workspace into the function?
Herschel Pangborn
el 18 de En. de 2022
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 18 de En. de 2022
0 votos
"In this example, the top model uses a signal object in the MATLAB® workspace to define the error data store. This is necessary because data stores are visible across model boundaries only if they are defined by signal objects in the MATLAB workspace or a data dictionary. The model specifies code for the PreLoadFcn model callback parameter that creates the signal object. This code executes before the model loads."
So you can create data stores that self-initialize at load time, and you can route them as signals to become an additional parameter nto the function block.
Categorías
Más información sobre Discontinuities en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
