How to generate .m file from GUIDE GUI?

조회 수: 6(최근 30일)
László Arany
László Arany 2013년 11월 21일
답변: Edwin Fonkwe 2017년 9월 25일
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
Jan
Jan 2014년 11월 22일
@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.

댓글을 달려면 로그인하십시오.

답변(3개)

Iain
Iain 2013년 11월 21일
Look for an *.asv file with the same name.
  댓글 수: 1
László Arany
László Arany 2013년 11월 21일
I couldn't find such file unfortunately. I modified the question accordingly.

댓글을 달려면 로그인하십시오.


Vishal Rane
Vishal Rane 2013년 11월 22일
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
László Arany
László Arany 2013년 11월 22일
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?

댓글을 달려면 로그인하십시오.


Edwin Fonkwe
Edwin Fonkwe 2017년 9월 25일
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!

Community Treasure Hunt

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

Start Hunting!

Translated by