Sie sind auf Seite 1von 4

05-10-2010 HowTO:Create standalone executable…

Onecore

Developer Network

Search this website… Search

Home
About
Advertise
Archives

Fortran To C Migration
All Popular Fortran Dialects Extremely Accurate and Complete
www.prom ula.com

HowTO:Create standalone executable for


matlab file
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 7.1.0.246 (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.

Code:
we’ll write simple program that uses plot function to draw the 2-d graph of two varibales.

function graph
a=[12,54,33,80,26];
b=[44,25,72,98,66];
plot(a,b);

After writing the code,save the file with filename “graph.m”.

Code explaination
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.
onecore.net/howtocreate-standalone-… 1/4
05-10-2010 HowTO:Create standalone executable…

Compiler configuration
First thing we need to do is configure the compiler.In the command prompt of the matlab,type

mbuild -setup

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:
[1] Borland C++Builder version 6.0 in D:\Program Files\Borland
[2] Lcc C version 2.4.1 in D:\MATLAB71\sys\lcc

[0] None

Compiler: 1

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
From template:D:\MATLAB71\BIN\win32\mbuildopts\bcc56compp.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

Compilation
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.
onecore.net/howtocreate-standalone-… 2/4
05-10-2010 HowTO:Create standalone executable…

Related posts:

1. Howto:Sound Generation in Turbo C ++


2. How To : Create Simple flash site
3. How To: Programming in python
4. MinGW in easy steps
5. How to:python programming under Ubuntu

C++ Database C++


High Scalability, High Availability Large C ++ Ex pe rts are R e ady to He lp. Join Now
Data Se ts, High Pe rform ance for Fre e .
www.ve rsant.com /obje ctdatabase C Fanatic.com /C PlusPlus-Program m ing

Comments

1. Alfia says:
April 1, 2007 at 11:58 am

Hey! Hi… Just wanted to thank you so much for that little help note… It was of immense help at the
last minute.
THANK YOU SO MUCH.
Great job!

2. Dan says:
April 2, 2007 at 2:15 am

Thank you so much, you saved me so much time.

3. RAJKIRAN.S.N says:
April 24, 2007 at 4:48 am

nada it works on it …..

Featured Articles

Squeeze Page using Genesis Framework


.NET- What is assembly ?
What is the difference between data grid, data list and repeater ?
How the ASP.NET authentication process works ?
SQL Server – Normalization

onecore.net/howtocreate-standalone-… 3/4
05-10-2010 HowTO:Create standalone executable…
Java Graph Library
Create Impressive Graphs and Charts Fast
3D Engine. Free Download
www.bfo.co.uk /graphlibrary
HCS12X & Xgate Dev Tools
Compiler, BDM Debug, Flash Program and
simulator for Freescale Micros
www.cosm ic-software .com
C++ Database
High Scalability, High Availability Large Data
Sets, High Performance
www.ve rsant.com /obje ctdatabase
ASN.1 CDR Tools
ASN.1 CDR compiler to C/C++/Java Full
XML/ASCII support. Free eval.
www.oss.com

Return to top of page

© 2010Onecore

onecore.net/howtocreate-standalone-… 4/4

Das könnte Ihnen auch gefallen