Unable to save file in simulink dictionary because not serializable
4 次查看(过去 30 天)
显示 更早的评论
I am using the function addEntry to set the dictionary value "pangu" as a structure inside the dictionary "userDictionary". The structure "pangu" contains a filw which connects an S-function inside the simulink model to an external program, "pangu.ClientLibrary.ClientConnection@503a7990". When I try to use addEntry with this structure, I receive the following warning:
Warning: pangu.ClientLibrary.ClientConnection@503a7990 is not serializable > In Data.setDictionaryValue (line 15)
Of course the field which should contain the client connection results empty and the connection becomes not available, thus the impossibility to simulate the model.
Do you know of any way to overcome this "not serializable" problem?
Thank you
0 个评论
回答(1 个)
Dhruv
2024-5-24
Hi Zeno,
A potential reason why you might be encountering this is because MATLAB does not support the serialization of database connection objects. This design choice prevents the saving and reloading of potentially disconnected database connections from ‘.MAT’ files.
In order to address the ‘not serializable’ warning and maintain your model's functionality, consider storing connection parameters separately and re-establishing the connection dynamically at runtime, rather than saving the connection object itself within the Simulink dictionary.
Hope this helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!