フィルターのクリア

Restoring library links

1 回表示 (過去 30 日間)
Gagik Hakobyan
Gagik Hakobyan 2011 年 12 月 1 日
Hello All, I have a instantiated library block in my model, which link is set to inactive. I have removed some parameters from its library block. Also, the instantiated block has some parameters which values are differ from the library block and i do not like to change them. How can I apply library block changes in instance without loosing local changes. It can be done via gui(Link Options->Restore Link), but I need to do this programmatically(via set_param command)
Any help is appreciated. Thanks

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 12 月 3 日
You need to be very careful about this type of operation. Depending on what do you mean by "parameters", I am not sure if you can merge the changes made both on the library blocks and the instantiated blocks in the model. But if you say that the GUI operation via Link OPtions -> Restore Link can achieve what you want, then you can do it in script. Try an example first to make sure it works before you apply to the whole model.
LibraryBlocks=find_system(MyModel,'FollowLinks','On','LookUnderMasks','All',...
'LinkStatus','inactive');
% restore libraries, from inside to outside because library might be
% nested
for i=length(LibraryBlocks):-1:1
try
Lib_Model=get_param(LibraryBlocks{i},'AncestorBlock');
Lib_Model=regexprep(Lib_Model,'/.+','');
open_system(Lib_Model);
set_param(LibraryBlocks{i},'LinkStatus','restore');
fprintf(1, 'Info: Restore block ''%s'' from library file "%s".\n\n',LibraryBlocks{i},Lib_Model);
catch %#ok<*CTCH>
fprintf(2, 'ERROR: Can not restore block ''%s'' to library file "%s".\n\n',LibraryBlocks{i},Lib_Model);
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Environment Customization についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by