How to get the order of Simulink blocks based on their pin connection

5 vues (au cours des 30 derniers jours)
Ganesh Hegade
Ganesh Hegade le 17 Fév 2017
Commenté : Ganesh Hegade le 23 Fév 2017
How to get the order of Simulink blocks based on their pin connection.
For Example: From attached Simulink model (This model has no meaning. created only to give idea about my problem ), I want to get the order of blocks based on pin connection instead of their alphabetic order.
The order should be like (Expected Output):
1. Integrator,Second-Order Limited Block
2. Integrator or Rate Limiter Dynamic Block
3. Rate Limiter Dynamic or Integrator Block
4. Lookup table Dynamic Block
5. Data type Conversion block
6. n-DLookup Table Block
But Currently I am getting order based on Aplhabatic name of Blocks (Refer below image for the results uisng 'find_system' command.)
(Current Output):

Réponses (1)

Hari Desanur
Hari Desanur le 22 Fév 2017
I don't think you can do this directly but you might be able to use the 'Position' property of a Block to get the desired order of the blocks.
Refer to the 'Position' property in this documentation page -
  1 commentaire
Ganesh Hegade
Ganesh Hegade le 23 Fév 2017
I am already getting order of the Blocks by using their Position. But it doesn't work for all conditions. For example user may place the Blocks in random order. So i am looking for some solution based on Block 'handle' and 'Portconnectivity'. Below is the current solution used by me.
caBlocks = find_system(gcs,'SearchDepth',1,'Type','Block');
caPositions = get_param(caBlocks,'Position');
nLeftPos = cellfun(@(c)c(1),caPositions);
[~,nOrderIdx] = sort(nLeftPos);

Connectez-vous pour commenter.


En savoir plus sur Simulink Functions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by