Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting handles of multiple selected blocks in Simulink

Is there's any way to get handles of all selected block using simulink APIs ?

Suppose I select few blocks using mouse, how could I get handles of all selected blocks in form of an array or cells using simulink APIs ?

With gcbh it just gives the handle of recently selected block only.

Basically I want to auto-generate corresponding "From" blocks of all selected "Goto" Blocks and vice-versa.

Matlab Version : 2010b

like image 206
P0W Avatar asked Dec 28 '25 07:12

P0W


2 Answers

This gives you the names of all the selected blocks:

blockNames = find_system('Type', 'Block', 'Selected', 'on')

You should be able to obtain the handle to the blocks by iterating over the cell array and calling get_param(blockName, 'handle'):

for i = 1:length(blockNames)
    blockHandles(i)= get_param(blockNames{i},'handle');
end
like image 158
Christian Reimer Avatar answered Dec 30 '25 22:12

Christian Reimer


This doesn't answer the question directly, but if you want to auto-generate "From" blocks, I suggest the following from the File Exchange:

http://www.mathworks.co.uk/matlabcentral/fileexchange/40117-autofromtag

I have used it before and it works very well.

like image 33
am304 Avatar answered Dec 30 '25 23:12

am304



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!