copying simulink blocks properties from one model to another model

2 views (last 30 days)
Hi, i have two versions of same model with some changes and i want to copy simulink block properties (Backgroundcolor and Foregroundcolor) from older version to the newer version for all blocks which matches between older and newer model. Below code is working perfectly in matlab 2012a:
load_system(OLD_MDL); % Loads the Old model to workspace% S_Blocks = find_system('OLD_MDL','Type','Block'); %get the list of simulink blocks in old model% S_FG_Colors= get_param(S_Blocks,'Foregroundcolor');%get Foregroundcolor of each and every block% S_BG_Colors= get_param(S_Blocks,'Backgroundcolor'); %get Backgroundcolor of each and every block%
load_system(NEW_MDL); D_Blocks = find_system('NEW_MDL','Type','Block');%get the list of simulink blocks in new model% if (strcmp(SName,DName)) %this loop search for each simulink block from old model in new model and copies the Background and Foreground color if match found% Match_Found=0; for k=1:length(S_Blocks) for j=1:length(D_Blocks) Match_Found=strcmp(S_Blocks{k},D_Blocks{j}); if Match_Found set_param(D_Blocks{j},'Foregroundcolor',S_FG_Colors{k}); set_param(D_Blocks{j},'Backgroundcolor',S_BG_Colors{k}); end j=j+1; end k=k+1; end save_system('New_MDL'); close_system('NEW_MDL'); close_system('OLD_MDL');
Here is my problem: Same above code is not working in matlab 2007. Looks like load_system function is not working same between matlab 2007 and 2012. In Matlab 2012 load_system is loading the model to workspace but not opening, where as in matlab 2007 it is not loading the model but just opening the model and hence, find_system function is not able to collect the simulink blocks in the above code. can someone please help me why it is not working in matlab 2007 and how to fix it. thank you.

Answers (0)

Categories

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

Community Treasure Hunt

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

Start Hunting!