How can I disable the Iced status which prohibits changing the Script property? ('Can't change property while iced')

7 views (last 30 days)
I want to change the Script property of the Attribute function block (SimEvents-Toolbox), but I have a problem with the 'Iced'-Property in the Chart.
Referring to the steps shown in
I created following code:
% new model
mona = 'Test';
new_system(mona,'Model','ERRORIFSHADOWED');
open_system(mona);
% new block 'Attribute Function'
add_block('simeventslib/Attributes/Attribute Function','Test/manipulate_attributes');
% get hanlde for Stateflow.EMChart
sf = sfroot();
sysAF = find_system('simeventslib/Attributes/Attribute Function/MATLAB Function/ SFunction ','LookUnderMasks','all');
AFsFcn = get(cell2mat(get_param(sysAF,'handle')));
HsFcn = sf.find('Path',AFsFcn.Path,'-isa','Stateflow.EMChart');
HsFcn.Locked=0;
% I want to place my code here:
HsFcn.Script='Function_Code';
I get following error:
Can't change property while iced
Error in manipulateAttributeFunction (line 33)
HsFcn.Script='Function_Code';
Changing the Fcn Code by doubleclicking on the Attribute Function block and typing via Editor still works. Any ideas? Thanks in advance!
Edit 14.01.2015:
For anyone working on this and searching for solutions... the Matlab Support Request helped me to solve the problem:
>>
The reason that you were getting error messages relating to the block being "iced" is because you were trying to change the block within our shipped 'simeventslib' as opposed to the block that is referenced in your model. Our shipped libraries are locked with a read-only flag, called 'iced', that you wont be able to modify. You can see that the handle of the object you were getting points to the library by typing 'get(HsFcn).
Instead of grabbing a handle to the shipping library block, you can find the handle to your block, which should be modifiable in the same way. The following code finds the EM Charts in your model only and then modifies them. I have confirmed on my end that this code runs without error:
% get hanlde for Stateflow.EMChart
rt = sfroot();
m = rt.find('-isa', 'Simulink.BlockDiagram', '-and','Name', mona);
HsFcn = m.find('-isa','Stateflow.EMChart');
% I want to place my code here:
HsFcn.Script='Function_Code';
<<

Answers (1)

Feng Liu
Feng Liu on 14 Jan 2015
You can try to use get_param(HsFcn.Path,'LinkStatus') to check if HsFcn is "inactive" or not.
I had the same error message when I try to make change to a library.

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!