Copying a block and dynamically changing the name and sub block names.

6 Ansichten (letzte 30 Tage)
I have several blocks, all of which contain a matlab script and input/outputs with To Workspace blocks to log the data. I would like to be able to copy a block, and dynamically when changing the copied block name, for the To Workspace variable name to change accordingly.
I know this can be done with a callback and set_param, but my problem is the block path: When copying/pasting a block, a new path is generated, but this new path is not considered in the callback, therefore it will only change the original block.
Is there a way to dynamically write the path of a block in a callback or code, such that if I copy and paste this block, the aforementioned situation works?
Thanks!

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 9 Jan. 2019
The question is not very clear. You might be able to use gcb, gcbh, getfullname().
  1 Kommentar
Rodolfo Villanueva
Rodolfo Villanueva am 11 Jan. 2019
Sorry for that! But I found a way. It is indeed with gcb, but the key was to use the namechangefcn for a callback. This way, everytime somebody changes the name, my callback code is executed to read the new name and change the name of the variable.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Model, Block, and Port Callbacks finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by