PreSaveFcn Callback

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.

 采纳的回答

TAB
TAB 2012-6-27
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;

5 个评论

This will not be done by command line, the user will save the model by save as button from MenuBar.
The problem is that this should work when the user opens a new model, that means 0 variables in workspace. I have to save the data in a callback, copy the info in some file and clear the workspace, but in the PreSaveFcn callback I already get the new name.
I do not know the name of the new model so i can not copy the information before the user selects a name with save as.
I think it is not possible to save the last model name in PreSaveFcn callback when model is saved using "Save As". Because when model is saved using "Save As", second model becomes the saved and latest appeared model. Previous model closes automatically.
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.
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.
See http://www.mathworks.in/help/toolbox/simulink/ug/bqt2_v7-1.html
Adrian Dronca
Adrian Dronca 2012-6-27
编辑:Adrian Dronca 2012-6-28
I will try it, sounds good. I will give my feedback afterwards
Thank you.
Edit: It is working, thanks for the info

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Simulink 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by