Attemp to modify a read-only model workspace

49 views (last 30 days)
Chuyen
Chuyen on 25 Mar 2024
Commented: Piyush Kumar about 6 hours ago
Hello all,
I am getting this error when I tried to remove an parameter out of my Model workspace by .m code:
mdlWks = get_param(mdlName,'ModelWorkspace');
clear(mdlWks, objName);
However, I could not run this code line clear(mdlWks, objName) which was specified as a read-only model workspace without any reasons. This command worked for my other blocks but this did not worked.
Do you know how can I realize it is a read-only model workspace? And how can I access to this workspace to remove this parameter?
  2 Comments
Divyanshu
Divyanshu on 1 Apr 2024 at 9:36
Hi Chuyen,
It is difficult to reproduce the issue without model and the script file with which you are currently working. Can you share the model and the (.m) script file?
Piyush Kumar
Piyush Kumar about 4 hours ago
Hi Chuyen,
The error message that you are receiving(regarding read-only model workspace) might be due to an attempt to access variables that are created at the update step in the lifecycle of execution of a Simulink model. The model workspace of a Simulink model becomes read-only during the update phase of the execution. To access it,
Go to the "MODELLING" tab
Open "Model Explorer"
Under the model, you will find "Model Workspace".
I also faced this error message with my model which has a callback function trying to initialize a "Simulink parameter" variable. I created this variable in the "Model Workspace" through "Model Explorer".
However, I was able to successfully delete that variable from the model workspace after the execution of the model using a clear function. Are you using clear() during the execution of the model?
If you are using callbacks, then you may trace callbacks to find out which callback is causing the issue - https://www.mathworks.com/help/simulink/ug/callback-tracer.html
As suggested by @Divyanshu, if you share the model and the code to reproduce this, it will be easier to investigate it.
Hope this helps.

Sign in to comment.

Answers (0)

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!