Thursday, 18 December 2014

Matlab 2014b in Ubuntu 14.04: solution to NVIDIA graphic card support problem

For the installation of matlab2014b in ubuntu, please follow the instructions in the following link:
https://help.ubuntu.com/community/MATLAB

When I tried to plot 3D image (2D density surface), the rendering of the image was bad. It looks like that there are missing pixels. 

This is because Nouveau kernel driver does not support matlab. As a result, matlab is using its OpenGL software option for rendering.

The following gives the instruction to install Nvidia driver in ubuntu and reset OpenGL in matlab.
  1. in a ubuntu terminal run the following commands:
  • sudo apt-add-repository ppa:xorg-edgers/ppa
  • sudo apt-get update
  • sudo apt-get install nvidia-current nvidia-settings
  1. reboot your PC
  2. run matlab
  3. in matlab, run the command line:
  • opengl('save','hardware')
The matlab2014b should produce nice 3D images now.
Enjoy!

Leave me a comment if you think this post is useful for you.
-shun

Matlab 2014b in Ubuntu 14.04: solution to mex gcc version problem

For the installation in ubuntu, one can follow the instructions in the following link:
https://help.ubuntu.com/community/MATLAB


However, I could not mex a c code in ubuntu.
The c code is mtimesx.c, and I use the following command:
mex -v -DDEFINEUNIX -largeArrayDims mtimesx.c -lmwblas -lmwlapack

It gives the following error:

Warning: You are using gcc version "4.8.2".  The version
         currently supported with MEX is "4.7.x".
         For a list of currently supported compilers see: 
         http://www.mathworks.com/support/compilers/current_release/

-> gcc -c  -I/usr/local/MATLAB/R2014b/extern/include -I/usr/local/MATLAB/R2014b/simulink/include -DMATLAB_MEX_FILE -std=c99 -D_GNU_SOURCE  -fexceptions -fPIC -fno-omit-frame-pointer -pthread  -DDEFINEUNIX -O -DNDEBUG  "mtimesx.c"

mtimesx.c: In function ‘mexFunction’:
mtimesx.c:592:10: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
      ans = mexGetVariablePtr("caller","OMP_SET_NUM_THREADS");

          ^
-> gcc -O -pthread -shared -Wl,--version-script,/usr/local/MATLAB/R2014b/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -o  "mtimesx.mexa64"  mtimesx.o  -lmwblas -lmwlapack -Wl,-rpath-link,/usr/local/MATLAB/R2014b/bin/glnxa64 -L/usr/local/MATLAB/R2014b/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++

/usr/bin/ld: cannot find -lstdc++
collect2: error: ld returned 1 exit status

    mex: link of ' "mtimesx.mexa64"' failed.

Unable to complete successfully.


The solution to this is to change the gcc version for mex. However, in this matlab 2014b, it does not allow you to choose gcc compiler in mex setup function. The way to do it is the following:

  1. install gcc-4.7 and g++-4.7 in ubuntu through synaptic package manager.
  2. then find the file "mexopts.sh" in folder .\home\.matlab\R2014b and open the file. you may need to change the permission of the file in order to modify it.
  3. find CC='gcc' in "mexopts.sh", and change it to CC='gcc-4.7'
  4. find CXX='g++' in "mexopts.sh", and change it to CXX='g++-4.7'
  5. save the file.
Then mex functions well in matlab. 

Please leave a comment if you find it is useful. 
-Shun

Wednesday, 8 January 2014

four propeller helicopter

four propeller helicopter

used for good moving.
used for single person transportation.

Could we have four stands consist of four superconductors.