Can you create an object in Simulink that can be referenced by multiple MATLAB Fcn blocks?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I've attached an image with my current Simulink set-up. I am needing to replace the Interpreted MATLAB Fcn blocks with MATLAB Fcn blocks in order to make my Simulink code generation compatible. However, I am struggling to find a way to mimick this similar OOP approach - where I am essentially creating a global object that is being referenced and manipulated by multiple blocks.
With the MATLAB Fcn block, it is only creating a local object for that specific block. It cannot be referenced and manipulated by another MATLAB Fcn block. I run into a similar issue when trying it with MATLAB System blocks. Is there a workaround for this to get this "global object" character?
5 comentarios
Umar
el 8 de Ag. de 2024
Hi @Roop,
To address your query regarding, “ I don't belive this method works for objects of user-defined classes. For instance, my object has properties that return variable size structs, App Designer UI's, and other complicated data types. Are there any addtional potential workarouds?”
I do understand that the set_param and evalin approach may not directly work for objects of user-defined classes with complex data types unless you utilize global variables within MATLAB because by declaring a variable as global within a function block, you can maintain its value across multiple function calls. Hope this helps.
Respuestas (1)
Paul
el 11 de Jul. de 2024
Hi Roop,
If you want to use global data inside Matlab Function blocks, start from Use Global Data in MATLAB Function Blocks to assess if any of the provided methods are sufficient for your use-case.
I do not know if the Matlab Function blocks support use of user-defined classes (UDC) as seems to be the case here. Even if so, I'm not sure if a UDC instance can be used as a global object, and, frankly, I suspect that won't pe possible because this Simulink paradigm is based on Simulink.Signal objects. If it isn't there may be other workarounds.
4 comentarios
Paul
el 8 de Ag. de 2024
Is there really a need to update the object during simulation?
Or do you just need to iterate on the data during simulation?
Ver también
Categorías
Más información sobre Simulink Functions 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!