Unable to save file in simulink dictionary because not serializable

조회 수: 4 (최근 30일)
Zeno Pavanello
Zeno Pavanello 2021년 12월 1일
답변: Dhruv 2024년 5월 24일
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