I have the following problem. Let us say, we have some GUI written in Matlab. Let it be
mygui.fig and mygui.m.
OK, now I want to rewrite this gui and keep prev version of it. So, I copy these two files to mygui_new.fig and mygui_new.m.
We all know, that when we run something.fig, Matlab tries to find something.m in order to perform responses on our actions. However, when I'm trying to run my mygui_new.m, Matlab tries to read scripts from mygui.m giving me warnings like:
Warning: Name is nonexistent or not a directory: ..\..\matlab\PostProcess\
In path at 110
In addpath at 87
In mygui at 22
In #(hObject,eventdata)SemiSuperviseTool_main('video_name_popupmenu_CreateFcn',hObject,eventdata,guidata(hObject))
In graphics/private/hgloadStructDbl at 95
In /usr/local/MATLAB/R2013a/toolbox/matlab/graphics/hgload.p>hgload at 70
In openfig at 72
In gui_mainfcn>local_openfig at 286
In gui_mainfcn at 159
In mygui_new at 46
So, we see that Matlab is really starting from my new version of script, but then for some reason tries to load an old one. If I delete old files at all, GUI will not run.
Here is another my post:
No breakpoints after gui figure copying?
The solutions I've described there doest not work here.
Any ideas?
Thanks!
The FIG file stores tags and callbacks that have names tied to the original M file. So, to truly replicate, one has to at least edit those changes for the new FIG file using GUIDE.
Related
I'm attempting to get Octave working in Jupyter and while I can execute basic math, I cannot get plots to work. Regardless of what type of graphics library I try to use, I get an error similar to this:
error: feval: function '__init_gnuplot__' not found
error: called from
graphics_toolkit at line 98 column 5
Here's the code that faileds:
register_graphics_toolkit('gnuplot');
available_graphics_toolkits()
graphics_toolkit("gnuplot");
I did some investigation and my best guess is that it looks like it's looking for a file called __init_gnuplot__.cc, based on the fact I found a file with a similar name but ends with '-tst'. However, that file doesn't exist and grepping the entire file structure under the octave directory doesn't find any instances of the function in the error.
Has Anaconda removed that functionality? Does anyone know where that '__init_gnuplot__' function is supposed to be located? Or, better yet, does anyone know how to resolve this?
I am using Matlab to do some image processing on a cluster that uses Sun Grid Engine. On my personal laptop the code runs fine but when I run it on the cluster I get several errors of files that cannot be found. For example a .nii (nifti) file that exists (I can read it when I run matlab interactively in the shell) is not found. An excerpt from the output log:
{^HError using load_nii_ext (line 97)
Cannot find file
"/path/imageFile.nii".
And I also get errors from an xml structured file (that needs to have a .mps extension to be readable by a postprocessing toolbox, which all worked fine on my own laptop). Another excerpt from the output log:
/path/pointSetFile.mps exists
{^HError using readpointsmps (line 24)
Failed to read XML file
/path/pointSetFile.mps.
In this second error message the first line is the output I get from including in the script,
if exist(strcat(folder, fileName), 'file') == 2
disp([strcat(folder, fileName) ' exists'])
end
So it's weird that 1) I can see the files, 2) I can open them manually with Matlab, 3) according to the matlab function exist() they do indeed exist, but when the functions xmlread() and read_niigz() want to open them they suddenly can't be found.
As extra information: I run the scripts with the flags -nodisplay -nodesktop -nosplash, and I currently run the scripts as 2 tasks with the SGE. Memory should be good, I give it 5GB and all my images combined are about 1.5GB.
I'm using absolute paths starting at the root /, have been reading the paths letter by letter about 200 times now and have no clue anymore what's going on.
I have solved the problems now.
#Xiangrui Li pointed out in the comments that the missing .nii files were due to interference with the unzipping, reading and deletion of the .nii and .nii.gz files. That was indeed the problem. Thanks!
I found that the second problem was due to umlauts in the filenames. Apparently there was a difference between how the system and matlab and even other processes involved encode the filenames. Removing the characters with umlauts solved the problem.
My problem is as described. My script downloads files through an external call to cmd (using the system function and then .NET to make keypresses). The issue is that when it tries to fopen these files I downloaded (filenames from a text file I write as I download), it doesn't find them, causing an error. When I run the script again after seeing it fail, it works but only up to the point where it's trying to download/call new files again, where it runs into the same problem.
Are new files downloaded during when a script is running somehow not visible to the search path? Because the folder is most definitely in my search path (seeing as it works outside of during-script downloads). It's not that it isn't getting the files fast enough either, cause they appear in my folder almost instantly, and I've tried a delay to allow for it to recognize it, but that didn't work either.
I'm not sure if it's important to note that the script calls an external function which tries to read the files from the .txt list I create in the main script.
Any ideas?
The script to download the files looks like so:
NET.addAssembly('System.Windows.Forms');
sendkey = #(strkey) System.Windows.Forms.SendKeys.SendWait(strkey);
system('start cygwinbatch.bat')
pause(.1)
sendkey(callStr1)
sendkey('{ENTER}')
pause(.1)
sendkey(callStr2)
sendkey('{ENTER}')
pause(.1)
sendkey('exit')
pause(2)
sendkey('{ENTER}')
But that is not the main reason I am asking: I am confident that the downloads are occurring when the script calls them, because I see them appearing in my folder as it called. I am more confused as to why MATLAB doesn't seem to know they are there while the script is running, and I have to stop it and run it again for it to recognize the ones I've downloaded already.
Thank you,
Aaron
The answer here is probably to run the 'rehash' function. Matlab does not look for new files while executing an operation, and in some environments misses new files even during interactive activity.
Running the rehash function forces Matlab to search through its full path and determine if there are any new files.
I've never tried to run rehash in the middle of an operation though. ...
My guess is that the MATLAB interpreter is trying to look ahead and is throwing errors based on a snapshot of what the filesystem looked like before the files were downloaded. Do you get different behavior if you run it one line at a time using F9? If that's the case then you may be able to prevent the interpreter from looking ahead by using eval().
I have just installed PottersWheel (latest version) for Matlab (version R2014a) on 64-bit machine. When attempting to use the 'New Model' button I get an error which I have pasted below:
-------------------------------------------
Problem detected at 2014-10-17 14:06:01:
Attempt to reference field of non-structure array.
Line 128 of pwGetFieldWidths.p
Line 170 of pwModel2CellArray.p
Line 126 of pwSaveModel.p
Line 607 of pwCreateModelGUI.p
Line 175 of pwCreateModelGUI.p
Line 95 of gui_mainfcn.m
Line 60 of pwCreateModelGUI.p
Matlab 2014a (mexw64) PottersWheel 3.1.0
-------------------------------------------
Since apparently there is no way to access .p files as they are protected. Does anybody know how to fix this problem?
The .p files are obfuscated MATLAB functions (or kind of object files). So, you cannot edit them. The possibilities are:
You read the documentation carefully, and verify that your arguments obey the requirements;
If #1 fails, you contact the author that holds the source and ask him/her for advice and bug fixing.
If #2 fails, you look for an de-obfucscator/de-compiler.
I hit something wrong in Matlab and my code was transformed into unreadable strings of symbols (I . I suspect that this is a simple question for cs people, but I'm just an academic-in-training "end" user of code --that is, I know little theory and forget it easily, unfortunately.
I hit ctr+z but nothing happened, closed it and opened it again, but the symbols are still there. And it doesn't run, the error I get is:
The input character is not valid in MATLAB statements or expressions.
This is the beginning of my code, in its unfortunate current state:
MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Sun Oct 05 06:57:45 2014
"‰\*’fTøÄ^L3:!I]ƒÁCƒÒP>朳÷>—º0ç²öEEHÉm�0fÈçRHñ)—\¢ßZï³æ3öïû£óû�㬽ֻÞËó>ïûîZ‡£ñ-IŽj⻺ø«âÀ§ªú}ÕeßrÏè¼Qƒ3råó$G]µ¾O<ÈÎÉÊÈÍÊLuTø¨Õ4»ÕÁãò²ÇºFå–¯fØ P«iv«•8\¶\¶\¶œ¶œ¶œ¶Ff�¿â¼XuåÚŠ½•¥bï•«yÙ¹Cs®��ÕÊ»áßüJ»ËWÓìV+Ù‘a' |5Ínµ²#\¶\¶\¶œ¶œ¶œ¶»†Ére9+F4±šVyU:£ÂæËVÓl$T¸0±÷òe…ɬ�9C]W 5kPNîØœ¼Ê«9¹ƒ+{'3ÍVBš„´Jœ¶:8mupÚêà´ÕÁi«ƒÓV‡r~¨("¾ZAD|µ‚ˆr.±•�f+¡’¶~È°õC†2lý�aë‡[?äåŒØx)'«8mVÓ*¯–ƒÓn5Í‘3nÐy¡<›—ýòÃùt[ùj†Ü_®°WI«¼·|YüGâ9ËåpT´‚V³s._% 7–¯VÜèPHÍ•72{„+?g°Ê/§íê{Sm÷¦&"_YD†Ü+÷¦Úí%¹µÄ_IUG¼NVSv”×ÉñwõСþo‰‡E³Ä§ÐÍfæ&|ÓÈÍ©Y¥•ÞÆÍ°ëÏK‹×¿ô5°GÞзÃ�SØ„”Ýö/`mågf›ºê�;ŸÝÃÄéocÇÜ,µú‡
Ÿíçeƒ;îíáfr9c¯ú^¨ãûðöb§;ÞÙ^À¤ØÅǦ°‡÷ç§,Ø<…�¾°müá nöû{ÅÝÛ•zØCþ‡Îo×éÙ#gÿ;ãæc:ô[b2yÍÛ¼L~åz<ìÏ>æ†|^ÜÓÃ=Oélžg¦8¿ØÄú~�müIÞ°Ÿuæù÷²FKöþ‰Òžr3if>÷²æÕ&¿™þ“¿‡ºÙŒ›“žªu£Îž•60Ù$)p Áî�†76`ŠÉÆÉ�õ|¬‰?í°ÎÞJ†4ÑÙù~XÖHܸS‡ß�?ÙdŠä‚d?ä&ûØ´£µû—°¯™ú
ѯ�:¯TUç5/îo ôxÄÇd8ëž1¿ûMè]ÕùOûÙßó…À]Ûô�ø,3Øöñ‡[¤ÞkÂîÛMÄ;ÉÇ—
ÏòÅqñŠØV½q)ð±Û¤³Lx§õ¢sä1ß½ÎÝjÀn¦ä§XëE‘ãï}ågÌüágâß6?ô3¹\œ„�%>vR˜}C®ñ;釜b?»(àÒâ—
And so on.
Thanks!
Your file isn't code at all, it's a Matlab data file with the wrong extension. You can see this by running
>> x = magic(10); %// creates a 10x10 matrix
>> save('junk.m', 'x'); %// note .m extension rather than .mat
>> edit junk.m
You will see something like this in your editor window -
MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Sun Oct 05 14:21:38 2014
å³B1#V A6å³B1#V å³B1#V // etc etc, lots more junk here
which is what a .mat file looks like when you change its extension to .m and open it as code.
So, sadly, I think you have overwritten your code file with some data. If you rename your file to have a .mat extension and then load it in MATLAB, you will be able to see what the data is.
If you have some kind of backup, you may be able to get your code back. Otherwise you're out of luck.
P.S. I used to be "just an academic-in-training end-user of code" as well. I spent some time learning a little bit of CS theory and programming languages (on and off over the course of a year) and it has paid back 100x in productivity gains. Not only will you be able to solve many more issues on your own, you'll also be able to do things that you haven't even considered possible to automate your work, leaving more time for the "fun" bit of research. I highly recommend the time investment!
Check the Extension of your file:
In MATLAB you can use the command pcode, which preparses your MATLAB code to a form that is unreadable by humans, but runs exactly the same (actually, very slightly faster) as the original MATLAB code. What happens is that for each .m file you pcode, you'll get a new file with a .p extension. The .p file runs the same as the .m file, but is unreadable.