How to generate .m file from GUIDE GUI?

Hi,
I have created a GUIDE GUI in Matlab and wrote thousands of lines of code. I was moving a lot of objects in the GUIDE window, like 20 edit objects and some other stuff with the arrows on the keyboard. Everything got immensely slow, and Matlab didn't respond. I chose to terminate the Matlab process, and as I did, it asked me if I want to save the gui and also if I want to save the .m file. I clicked yes, and restarted Matlab.
After this, I had to face the most horrible experience I've ever had with any software: the GUIDE GUI (I mean the .fig file) is okay, but the .m file was replaced by a completely empty 0KB file .
I am absolutely desperate, I lost a week's worth of work with that .m file gone (I know, I should have made a backup copy from time to time). Does anyone have an idea if Matlab maybe has some temp folder or something like that, any way to retrieve the lost file?
I suspect this is impossible, in that case I need to regenerate the .m file to at least contain all the callbacks of the GUIDE GUI (the objects in the .fig file). Now if I click 'Save As...' it just saves the .fig file, and generates a new empty .m file. I know I can't get my lost code back, but I should be able to at least generate a .m file with all the callbacks (like when you save the gui for the first time).
Any help or suggestion is very much appreciated. Thank you, Laszlo
Edit1: Following Iain's suggestion I searched for the .asv file, unfortunately there was none on my computer. Therefore, the second part of the question is more important now, so that I don't have to recreate the whole GUI at least. Thank you.
Edit2: The Properties --> Previous versions section of the folder in Windows 7 did not have any backup unfortunately.

2 Comments

Guys, what's the answer to this? I also want to regenerate all the callbacks because my GUI script file was somehow corrupted. How does one regenerate all the callbacks?
@Alexei: The answer to this question is simple:
Recover the file from your backup. If you do not have a backup, the work is lost.
For your question see your own thread: It is not clear to me what "generate callbacks" means.

Sign in to comment.

Answers (3)

Iain
Iain on 21 Nov 2013
Look for an *.asv file with the same name.

1 Comment

I couldn't find such file unfortunately. I modified the question accordingly.

Sign in to comment.

Vishal Rane
Vishal Rane on 22 Nov 2013
If in windows 7, Check the Properties > Previous Versions for the concerned folder. By any luck if you have Windows Backups enabled or a restore point created in last couple of days, you will see an old version of the folder.
Alternatively use a retrival software like recuva. If file has been accidently deleted, you should be able to retrieve it.

1 Comment

Thank you for the answer. Unfortunately I couldn't use the previous versions, there was nothing there. It is a work computer, so I'll try to work my way through IT to try and use recuva.
In the meanwhile I would be interested in the second part of the question, i.e. if I have a GUI created in GUIDE with all the controls and graphic objects in a .fig file but no .m file with it, how can I create a .m file that has the standard opening function section and the callbacks of all controls? I mean the standard .m file that is generated when you save your GUIDE GUI for the first time?

Sign in to comment.

It's been a long time now since the first question. For what it's worth, I ran into a similar problem (Matlab 2017) on guide; to solve the issue, I created a new guide, copied the first guide panels (copying the panel includes all its children components) to the second one. BEFORE saving the new guide, I had to manually modify the tag names of the all components as they had defaulted to the generic naming format. Then I saved the work, and voila! A new .m file populated with all the callbacks was generated. Good luck!

Categories

Products

Asked:

on 21 Nov 2013

Answered:

on 25 Sep 2017

Community Treasure Hunt

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

Start Hunting!