Matlab is high performance interactive system that allows technical computation,analysis & program developement for engg.students. It is very easy to learn matlab,it takes just few hours to get arround it.There are two ways to write program for it, first is to use the command-line interpreter & compile your code line by line or use notepad to write the code and save the program in work directory of compiler & then execute.
The code you write is stored within the .m file. During demonstrations,if you want to mask the code,all you need to do is to create executable file from it. With such standalone executable,you can even show your work on computer that have no matlab environment in it. Here,i’ll explain how to create such standalone application. We’ll start with creating simple program then move onto configuring the compiler environment.
Before you begin
I assume that you use Matlab version 18.104.22.168 (R14) & have alternate compiler like Borland C++ builder 6 or Microsoft Visual studio 6 +. Even if you don’t have the compiler you can use the compiler provided by the Matlab.
we’ll write simple program that uses plot function to draw the 2-d graph of two varibales.
After writing the code,save the file with filename “graph.m”.
Let’s explore the code line by line.First I’ve written the function name “graph” same as that of filename such that there won’t be any conflict for compiler. Next two line creates a variables with multiple values. At the end,plot function is called to plot the graph of two variables a & b.
First thing we need to do is configure the compiler. In the command prompt of the matlab,type
Interpreter will respond to this command by showing following message.
Please choose your compiler for building standalone MATLAB applications:
Would you like mbuild to locate installed compilers [y]/n?
Type ,”Y” to answer this question. This will force the interpreter to display the list of compilers.e.g. The list shown below. Then it will ask for the choice for the compiler,answer in format 1,2 or 0 for none.
Select a compiler:
 Borland C++Builder version 6.0 in D:\Program Files\Borland
 Lcc C version 2.4.1 in D:\MATLAB71\sys\lcc
I have selected the Borland C++ builder, if you have other option then choose approproate compiler otherwise, you can select the LCC C compiler. Then it will ask you to verify the source.
Please verify your choices:
Compiler: Borland C++Builder 6.0
Location: D:\Program Files\Borland
Are these correct?([y]/n): y
After this it will generate the linker messages for the use of compiler.
Try to update options file: C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R14SP3\compopts.bat
Done . . .
--> ""D:\MATLAB71\bin\win32\mwregsvr" "D:\MATLAB71\bin\win32\mwcomutil.dll"" DllRegisterServer in D:\MATLAB71\bin\win32\mwcomutil.dll succeeded
--> ""D:\MATLAB71\bin\win32\mwregsvr" "D:\MATLAB71\bin\win32\mwcommgr.dll""DllRegisterServer in D:\MATLAB71\bin\win32\mwcommgr.dll succeeded
Once the compiler configuration is done,now you have to compile the program source code.Type the following line in the interpreter.
mcc -m graph.m -o graph
Interpreter will create the necessary linker files for the MAT file,once the process is completed you can see the standalone executable is created for the compiler. When you click on it, that will open the command line window & the graphical plot of your program.
I hope above information helps. This tutorial was tested with Matlab 7.1 . So for support of higher version, you should check out the Mathworks support & Forums.