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

blockdynamic nameMATLABset_paramsimulinkworkspace

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!

Best Answer

The question is not very clear. You might be able to use gcb, gcbh, getfullname().