|
%%
7 s2 T/ }4 a0 z9 J& I" ]clear;clc
! u' y" N$ [. b ~/ Bbdclose('all')1 ~$ p6 q) f6 e4 b8 q
dbstop if error
% `! N9 G. x" ^5 x4 s; xsys=gcs;3 h0 M* B! h/ B h; u7 q2 {
open_system(sys)0 ?) @! O0 d' ~( K% o8 J
[refMdls,mdlBlks] =find_mdlrefs(sys);6 Y9 q' S, y/ f8 g
num_refMdls=length(refMdls)-1;
- b8 k5 W( I) w6 a2 d* B%%' r. L% K; ?: u, r9 T
new_system('null_model_with_subsys')
% w c" R* l X4 J5 wopen_system('null_model_with_subsys'); p: \. J) `$ @+ Q [7 R
add_block('built-in/Subsystem', 'null_model_with_subsys/null_subsystem')# g* s! B0 w0 W5 N+ l" [
%%
) e' }0 q0 Q; P7 K4 L2 [% Vfor i=1:num_refMdls8 u# S: K7 Z+ F. K6 n, V
load_system(refMdls{i,1})7 ?/ y4 Q. T' s" L! y$ o: Z" v; [5 K
Simulink.BlockDiagram.copyContentsToSubSystem(refMdls{i,1},'null_model_with_subsys/null_subsystem')+ r( M$ L. O& E: k; ^% _% V
RepNames=replace_block(sys,'Handle',get_param(mdlBlks{i,1},'Handle'),'null_model_with_subsys/null_subsystem','noprompt');1 [1 Z# @- w+ _$ |
Simulink.SubSystem.deleteContents('null_model_with_subsys/null_subsystem')
0 P6 G# m2 c/ `: S bdclose(refMdls{i,1});6 z/ M& j2 L+ l. C! P& Z d
disp(['The ' num2str(i) '/' num2str(num_refMdls) ' model is converted into subsystem.'])
- _+ X$ u6 ^7 Y3 t# u' ] disp(['The converted reference model is ' refMdls{i,1}])$ r- _" R7 w# y4 a! E( w
end
2 C" k+ U/ a. p0 ^) Pbdclose('null_model_with_subsys') |
|