Copy matlab Simulink SUBSYSTEMS and SFUNCTIONS to another model
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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');
0 commentaires
Réponse acceptée
Ryan G
le 12 Juil 2012
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Subsystems dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!