Can you create an object in Simulink that can be referenced by multiple MATLAB Fcn blocks?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Umar
2024 年 8 月 8 日
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.
回答 (1 件)
Paul
2024 年 7 月 11 日
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 件のコメント
Paul
2024 年 8 月 8 日
Is there really a need to update the object during simulation?
Or do you just need to iterate on the data during simulation?
参考
カテゴリ
Help Center および File Exchange で Simulink Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!