필터 지우기
필터 지우기

Copy matlab Simulink SUBSYSTEMS and SFUNCTIONS to another model

조회 수: 3 (최근 30일)
Harsha
Harsha 2012년 7월 12일
Hi,
I have to seperate a top level model A and create another model with name B,C and D which contains Masked subsystems, unmasked subsystems and Sfunction models respectively.
While doing so, I am able to get which all are sfunction models and subsystems using "find_system".
But I am not able to copy these found models into a single model B, C or D respectively.
I have tried using "Simulink.BlockDiagram.copyContentsToSubSystem" command but am not able to get the solution.
Please let me know how can I copy all models which are found using "find_subsystem" from A to B , C or D model.
======================================================================
Please find the below code that I have written only for model B for copying subsystem models to model B i.e.,"new_model/System_Model"
%Load the model and find the subsystems and sfunctions
open_system('input')
NoOfMaskedSubsystem = find_system(gcs,'SearchDepth',6, 'LookUnderMasks','all', 'BlockType', 'SubSystem')
NoOfSfunctoin = find_system(gcs,'SearchDepth',6, 'LookUnderMasks','all', 'BlockType', 'S-Function')
NoOfNonMaskedSubsystem = find_system(gcs,'SearchDepth',6, 'LookUnderMasks','none', 'BlockType', 'SubSystem')
% %Create the new model having subsystems model for sfunction and subsystems
sys = 'new_model';
new_system(sys) % Create the model
x = 30;
y = 30;
w = 30;
h = 30;
offset = 60;
pos = [x y+h/4 x+w y+h*.75];
add_block('built-in/Subsystem',[sys '/System_Model'],'Position',pos)
open_system('new_model/System_Model');
%Add Top Level Model
Simulink.BlockDiagram.copyContentsToSubSystem('input', 'new_model/System_Model');

채택된 답변

Ryan G
Ryan G 2012년 7월 12일
You can copy the blocks you find directly without the copy contents function.
For example:
add_block(NoOfNonMaskedSubsystem{1},[gcs '/System_Model'],'Position',pos)
As for you copyContents call, the first input should be model A. I don't know what the 'input' is supposed to be in this case.
  댓글 수: 1
Harsha
Harsha 2012년 7월 13일
Hi. Fix works to copy only one subsystem to the new model. Is there any way that I can copy multiple subsystems to a single model at a time? Thanks in advance.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subsystems에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by