From: Nicolas on
Background: In order to normalize Simulink models I am trying to create a Matlab function that will put the model in a subsystem if a subsystem is not the first level of my model, changes the colors of my inputs/outputs and check the name of some of my blocks.

My problem is to find the most efficient way to put a model in a subsystem. My first idea was to create a new model with a subsystem and set the parameter Parent to the new model's subsystem but I tried it tells me that "block parameter 'Parent' is read-only".
So I am looking for another way to do this.
Can any of you offer some advice or a hint to a solution?

Thanks in advance,
Nicolas
From: Nicolas on
I just checked the add_block function and realized it made my question useless.

In order to do what I want, I need to use add_block('src', 'dest') with src being my system pathname and dest the subsystem pathname.
From: Nicolas on
I just checked the add_block function and realized it made my question useless.

In order to do what I want, I need to use add_block('src', 'dest') with src being my system pathname and dest the subsystem pathname.
From: Nicolas on
I was wrong the add_block command works only if the system to copy is already in a subsystem block. So I am still looking for a solution for my problem.

I have to work on Matlab 7.1SP3 (ie R14SP3).

I thought of two possibilities:
1) find all the elements (blocks and lines) of the system, then create the same block (with add_block function but the 'blocktype' parameter is not the name of the block in 'Simulink' library for example: Inport block type is In1 in Simulink library) in a subsystem and setting their properties as the one found with a 'get' on the copied block or line. This seems like it is going to take a long time to develop and take care of all the case so i abandoned this option.

2) using Simulink objects and their routines, select all the blocks and lines of the model to be copied, then copy them and paste them in a subsystem as would be done manually. This looks like the "easiest" way but I need to find help on those objected oriented commands and to find the instantiations of these block objects.