Compatibility between Mac and Windows MATLAB Gui
I am quite familiar with MATLAB, although not so much with writing GUIs in it. Now my boss gave me a MATLAB program with GUI which was developed on a Windows machine and runs there without problems. I copied it to my mac (osx 10.6.5 with MATLAB R2009b) using a USB memory st开发者_StackOverflow中文版ick and tried to work on the files on my computer.
When starting the GUI, some of the callbacks are executed, some not. I was able to open the figure file containing the GUI in GUIDE, but there cannot click on the callback fields in the Property inspector. Also some components are not shown in GUIDE which are visible when running the GUI. First I suspected it might be corrupted by changed newline characters, but learned that .fig files are binary, so this should not be the case. I opened the binary .fig file with a text editor and found the following ASCII line followed by binary data:
MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Tue Aug 10 17:11:57 2010
Are the GUIs created with MATLAB OS specific? Wouldn't this be really stupid?
I opened the files on the windows machine again and tried to export them or save them by specifying that I want them to be compatible with other operating systems but could not find an option like this.
Of course I researched this on google, and wondered that I did not really find something related. If an incompatibility exists, I think this would have been discussed, right?
Anyone knows about it or had the same problem before?
Hmmm, ok. Well, the answer is quite embarrassing but still bears some potential to learn from it. The folder that my boss gave me contained a lot of files and figures with similar names, like:
- bla1.fig
- bla.fig
- bla0.fig
the simple problem was, the first time I opened the figure with GUIDE I opened figure bla.fig instead of bla1.fig. After this I always used the reopen function of GUIDE and did not see that it was always the wrong file. this caused the problems.
==> so there is no incompatibility between Mac and PC, although I wonder why the platform is written in the file then
==> it could have been a problem with backwards-compatibility as the original figure was created with MATLAB 5
==> as @Adrian and @Mikhail pointed out: it would be very very useful to use a Version control system in order to prevent to have hundreds of files with different numbers where most of them are of no use anymore
There seems to be some incompatibilities between different platforms and also between different versions, from my experience (MATLAB 5, 6, and 7) also -- I've encountered similar situations many times.
I am not exactly sure when the GUIDE became available with MATLAB -- I first noticed about it when I was using the first version of MATLAB 7. (It used to be very unstable at first, but is very usable now. For example, I vaguely remember a critical issue with MATLAB 7 Student version. You had to download a patch to make the GUIs work.)
Does your boss know how the *.fig file was created and in which MATLAB version? Can you open the *.fig on the old version of MATLAB and display the GUI correctly?
Some functions have possibly become obsolete since the earlier version of MATLAB that was used to create the figure, and may be causing some minor problem with it. If that is the case, you can troubleshoot it by checking all the error and warning messages that appear on the Command Window (or the MATLAB Console.)
Also, you should be able to load the *.fig files on the workplace using the following command from the Command Window, assuming that the files are in MATLAB's search path.
load your_file.fig -mat
You should then see a structure dataset, and see all of the figure properties, etc. in that structure.
You can use the information to create a new figure without the GUIDE (GUI Development Environment / Tool).
I recommend you writing your own GUI app. It's not that difficult, with/without the GUIDE.
I recently opened a site with some Tips on MATLAB Programming for beginners and intermediate users, and update it in my spare time. If you have any specific question about GUI building, I may (or may not) be able to provide answers there...
精彩评论