フィルターのクリア

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 Center および File ExchangeSubsystems についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by