Subsystem output disconnected automatically before running simulation
Mostrar comentarios más antiguos
Hello people,
I have a subsystem. In the mask I added a checkbox in order to change the output of this block.
There are two possible outputs, and depending if the checkbox is checked or not, the single output of the block will be one or the other.
The problem arises when running the model. It seems that mask code is executed, so one output port is removed and substituted by the other one.
The problem is that in the upper level, the output is disconnected automatically. I did the same in other models and it was not behaving like this. Any suggestions?
Here is the code:
out = 'built-in/Outport';
term = 'built-in/Terminator';
if strcmp(get_param(gcb,'append_element'),'on')
oldOutput = [gcb '/Signals'];
newOutput = [gcb '/Signals +1'];
posOld = get_param(oldOutput,'Position');
posNew = get_param(newOutput,'Position');
orientOld = get_param(oldOutput,'Orientation');
orientNew = get_param(newOutput,'Orientation');
delete_block(oldOutput);
delete_block(newOutput);
add_block(term,oldOutput,'Position',posOld,'Orientation',orientOld);
add_block(out,newOutput,'Position',posNew,'Orientation',orientNew);
elseif strcmp(get_param(gcb,'append_element'),'off')
oldOutput = [gcb '/Signals +1'];
newOutput = [gcb '/Signals'];
posOld = get_param(oldOutput,'Position');
posNew = get_param(newOutput,'Position');
orientOld = get_param(oldOutput,'Orientation');
orientNew = get_param(newOutput,'Orientation');
delete_block(oldOutput);
delete_block(newOutput);
add_block(term,oldOutput,'Position',posOld,'Orientation',orientOld);
add_block(out,newOutput,'Position',posNew,'Orientation',orientNew);
end
clear out term
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Author Block Masks en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!