MATLAB Answers

Get selected objects (simulink)

58 views (last 30 days)
Adrian
Adrian on 12 Nov 2014
Answered: Gaganjyoti Baishya on 21 Jun 2020
Hi, when I want to run a script on a selected simulink object, I use "gca" to get its handle. If I select many objects, "gca" return only the last selected. Ho can I get handles of ALL selected objects?
Thanks Adriano

  0 Comments

Sign in to comment.

Accepted Answer

Orion
Orion on 12 Nov 2014
Hi,
gca won't return the selected object, but the current axe in a figure (get current axe)
I guess you meant gcb (get current block).
gcb only return one block.
if you want multiple blocks :
MyBlocks = find_system(gcs,'Selected','on')

  1 Comment

Adrian
Adrian on 13 Nov 2014
Yes I wanted to say gcb. Thank you. It works perfectly!

Sign in to comment.

More Answers (1)

Gaganjyoti Baishya
Gaganjyoti Baishya on 21 Jun 2020
To get an array of all selcted blocks use find_system(bdroot, 'Selected', 'on');

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!