MATLAB on GNU/Linux Tips
Here are a few tips for solving problems I've found running MATLAB on Linux, specifically I'm running
- MATLAB 126.96.36.199 (R14) Service Pack 3, Student Version, August 2005
- Ubuntu Edgy
Problems with uigetfileProblem: When using the uigetfile function, file selection doesn't work, you get a "file does not exist error" and it is not possible to change directory in the dialog.
before using the uigetfile function. Put that command in your MATLAB startup file so that it is set automatically each time you start MATLAB.
I got this tip from the following URL http://ntmm.org/~nt/matlab
Crappy Sound playbackFor some reason the matlab guys decided not to write a proper playsnd function for linux. The result is that whatever frequency sampling you use for playback with the
soundfunction, it will always play at the default sample rate of 8192 Hz. Sucks doesn't it? Fortunately someone has taken the time and effort to write a proper playsnd function for linux, you can find it here: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=111&objectType=file , this is a C source file, and in order to use it you need to compile it with the MATLAB mex function and put it somewhere on your MATLAB path... and here it comes other headaches, because the gcc version that your MATLAB was compiled with, probably doesn't match the current gcc version on your system, and in order to compile it you need to fiddle with the mexopts.sh file. Anyhow, here's how I did it last time:
mex -v playsnd.c
then try to call it with
If this doesn't work MATLAB is likely to have issues with the compiler. Copy the file mexopts.sh in the directory where you're compiling, and change the compiler name to the default gcc version of your current distribution gcc-4.1 worked for me last time. Try again playing the sound.
If the compilation has worked:
- rename playsnd.mexglx to playsnd2.mexglx and put that file in your path
- edit sound.m and make it call playsnd2 rather than playsnd
apt-get install alsa-oss
and the invoke MATLAB with