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

回答(1 个)

Dhruv
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!

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by