MATLAB Answers


PreSaveFcn Callback

Asked by Adrian Dronca on 27 Jun 2012
Accepted Answer by TAB

I want to save the model with a different name and get the model name of the previous model.

For example I have a model named 'model_A' and change it to 'model_B'

I set the PreSaveFcn callback, but in this callback i get the name of the new model 'model_B'.

How do i get the information for the old model ? Do I have to use a different callback ?

Thanks in advance, Adrian.


1 Answer

Answer by TAB
on 27 Jun 2012
 Accepted answer

Store the current model name in a variable and then save it with other name.

OldName = bdroot; % ie model_A
save_system(OldName, 'model_B'); save with new name;


yes :( you are right.

Do you know any callback function that is called right before the save ?

Maybe there are some workarounds I can use.

on 27 Jun 2012

You can do it by saving the model from a m-file as I suggested above.
Create your own Save As option in tool menu of the simulink GUI and call above code in the callback of that option.

I will try it, sounds good. I will give my feedback afterwards

Thank you.

Edit: It is working, thanks for the info

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!