Digital Communication Systems Simulation 


using MATLAB and C MEX


Compiler issue

I used GNU C compiler (gcc) to compile all the C source code. Although MATLAB provides it own C compiler (Lcc), its performance is far below gcc, which is considered as the best C compiler today. If you are using a Linux version of MATLAB, since gcc is the default Linux C compiler, the gcc can be selected by through command in MATLAB command shell:

 

 mex –setup

 

Follow the subsequent instructions and choose gcc as your default MEX compiler instead of MATLAB’s Lcc.

 

Windows users might need more effort to install gcc, but the process is straight forward, moreover, the software is free. First of all, you need to download MinGW installer from SourceForge.net. Install MinGW into you system, and run it. MinGW will download the necessary gcc’s files and guide you throughout the gcc installation. Later, you can update you gcc using MinGW.

 

Windows version of MATLAB will not recognize your installed gcc as a C compiler as in Linux counterpart. Fortunately we can use Gnumex in order to make MATLAB recognizes gcc. Run Gnumex’s MATLAB script through your MATLAB command shell, follow all the instructions, and you are done! Next time you issue a ‘mex’ command to compile your C source, it will use gcc as the default C compiler. You may check your default C compiler by issuing command:

 

 mex –v

 

An error message will follow since you are not compiling anything.  
 
There are some unexpected behaviour of the output of MEX files written for 32 bits environment compiled in 64 bits environment. Please use C-MEX codes in this page in 32 bits environment. I will update the codes for 64 bits operating system in the future.