Undo possible for programmatically changed simulink model?

4 views (last 30 days)
I've created some little helper-functions which help me e.g. to automatically create in- and outports for Subsystems or automatically reposition those ports. I'm using the add_block, add_line, set_param functions for this.
Is there any way to be able to undo those changes in Simulink if necessary?
Thanks in advance.

Answers (2)

Sujit Muduli
Sujit Muduli on 5 Mar 2018
Hi Raphael,
There is no API call available to do the UNDO operation.
But you may implement your custom UNDO function by keeping the handles for each of the blocks and lines that you are creating by your scripts.
Just wondering about your use case and where you are thinking of using this UNDO call could you please let me know about your workflow?

Raphael Klapczynski
Raphael Klapczynski on 5 Mar 2018
Hi Sujit, I use simple functions to e.g. automatically generate necessary inport and outport blocks for the selected Subsystem, reposition/reorder the child blocks of the selected Subsystem (to tidy up the model), etc...
There is always the possibility that you're doing something wrong and want to UNDO it. If I would implement a custom UNDO function it should work the same (usability)(same Buttons, same Hotkey-Buttons) as the original UNDO function which I don't know how to implement without collide with the original UNDO function (e.g. start an UNDO-step for my script without activating the original UNDO-function and vice versa). There needs to be an "observer" which decides if the next UNDO step is from my function or from the Simulink-UNDO. Don't know if that is possible.
Thanks in advance for your help.

Community Treasure Hunt

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

Start Hunting!