![]() |
|||
![]() |
|||
|
|
|||||
|
|
|
||||
|
|
|
||||
|
The Mathworks' mathematical software, MATLAB®, is the most popular language to use when simulating read channels. This C-like language is the tool of choice because it has powerful signal processing capabilities built-in and is relatively easy-to-use. What might take new modules of code in other languages can often be completed in a single line with Matlab. However, in writing tens of thousands of lines of MATLAB® code, we have encountered a few surprises. What follows is a brief description of a few important workarounds when compiling MATLAB® into C. PLEASE NOTE: We cannot be responsible for the accuracy of the following information or its suitability for your specific application. Use this at your own risk. General Issues with Compiling MATLAB® We have seen execution times decrease 15 to 25% for some modules we have created. These usually involve loops. When modeling the feedback control loops in the read channel, such as the AGC, PLL and LMS, loops cannot be avoided. Compiling MATLAB® code down to C is quite easy in MATLAB®, . . . provided you have followed all the rules in your original code. These rules include no eval statements and no writing or reading of ASCII files. You will need your own C(++) compiler (we use Microsoft's version 6.0) AND MATLAB®'s compiler. If you find yourself using a lot of eval statements in your code or you require the universality of writing and reading ASCII files, these following instructions should be helpful. They tell you how to create a MEX-file from an M-file; that is, how to compile MATLAB® code into C(++). This information is provided by our senior software developer, Barry Russell, and is based on MATLAB® version 5.3, R11. Creating a MEX file 1) All load and save commands must specify the exact variables being saved or loaded. The names of the variables being saved or loaded must be constants -- they cannot be variables as is typical in eval statements. If the filename is contained in a variable, use the functional form of load and save. ASCII files cannot be saved or loaded this way. 2) For ASCII files, use dlmwrite and dlmread to load or write ASCII files. When using
the values in the filename are read into x. 3) Replace "eval" statements with equivalent statements. 4) Replace all "axes(axes_handle)" statements with commands that directly set the "CurrentAxes" property of the figure to "axes_handle". I do not know why you have to do this step. This is not documented in the User's Guide. 5) To select the default compiler, type
6) To link and compile, type:
7) A .dll, several C files, and several C header files will be created. Only the .dll file is needed to run the compiled program. If fname.dll and fname.m are in the same directory, fname.dll is run, not fname.m.
MATLAB® is a registered trademark of The Mathworks. Please contact us for a free initial consultation. e-mail:
connect@ChannelScience.com |
|||||
|
|
|||||
|
|
|||||