How to rearrange subsystem block ports?

I would like to rearrange the input ports of my subsystem block (attached image) from:
  • Servo3_cmd
  • Servo2_cmd
  • Sevo1_cmd
  • MachEnv_setup
to:
  • Servo3_cmd
  • Servo2_cmd
  • MachEnv_setup
  • Servo1_cmd
Is rearranging the input/output ports of a simulink block possible?
Thank you!
NB : If anyone is interested, I found a better way to rearrange the ports. You go into the subsystem PMIO block and you set the port number and port position (Left/Right), which rearranges the inputs :)

 Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 29 Nov 2014
Use this code to get the different ports then use delete_line and add_line to arrange them
b=get_param('untitled/yoursubsystem','PortConnectivity')
n=numel(b) % number of blocks connected to block1;
out={};
for k=1:n
s=get(b(k).SrcBlock); % search for source blocks
if ~isempty(s)
out(end+1,1)={'Source'}
out{end,2}=s.BlockType;
out{end,3}=s.Name
end
end

7 commentaires

Danylo
Danylo le 29 Nov 2014
Awesome, thanks! Just tell me, please, where do I insert this code?
Azzi Abdelmalek
Azzi Abdelmalek le 29 Nov 2014
What do you mean?
Danylo
Danylo le 29 Nov 2014
I don't know where I insert the code that you wrote. Where do I write it?
Azzi Abdelmalek
Azzi Abdelmalek le 29 Nov 2014
The code is not complete, I gave you where to start, just adapt it to your case.
Danylo
Danylo le 29 Nov 2014
Yeah, but where do I insert it? Where do I physically write the code?
Azzi Abdelmalek
Azzi Abdelmalek le 29 Nov 2014
in an m-file, then run your m-file
Danylo
Danylo le 29 Nov 2014
Great, thanks!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by