MATLAB Compiler

Getting Started


Preface

Related Products

Using this Guide

Typographical Conventions

Introducing the
MATLAB Compiler

Introduction

Before You Begin

New Features

Compiler Licensing Changes

Uses of the Compiler

Creating MEX-Files

Creating Stand-Alone Applications

The MATLAB Compiler Family

Why Compile M-Files?

Stand-Alone Applications and Libraries

Hiding Proprietary Algorithms

Faster Execution

Upgrading from Previous Versions

MATLAB Compiler 2.0

MATLAB Compiler 1.2

MATLAB Compiler 1.0/1.1

Limitations and Restrictions

MATLAB Code

Stand-Alone Applications

Installation and Configuration

System Configuration for MEX-Files

UNIX Workstation

System Requirements

Installation

mex Verification

MATLAB Compiler Verification

Microsoft Windows on PCs

System Requirements

Installation

mex Verification

MATLAB Compiler Verification

Troubleshooting

mex Troubleshooting

Troubleshooting the Compiler

Using the MATLAB Compiler

Getting Started
with MEX-Files

A Simple Example - The Sierpinski Gasket

Invoking the M-File

Compiling the M-File into a MEX-File

Invoking the MEX-File

Compiler Options and Macros

Generating Simulink S-Functions

Simulink-Specific Options

Specifying S-Function Characteristics

Converting Script M-Files to Function M-Files

Stand-Alone
Applications

Differences Between MEX-Files and Stand-Alone Applications

Stand-Alone C Applications

Stand-Alone C++ Applications

Building Stand-Alone C/C++ Applications

Overview

Getting Started

Building Stand-Alone Applications on UNIX

Configuring for C or C++

Preparing to Compile

Verifying mbuild

Verifying the MATLAB Compiler

Distributing Stand-Alone UNIX Applications

About the mbuild Script

Building Stand-Alone Applications on PCs

Configuring for C or C++

Preparing to Compile

Verifying mbuild

Verifying the MATLAB Compiler

About the mbuild Script

Using an IDE

Distributing Stand-Alone Windows Applications

Building Shared Libraries

Troubleshooting

Troubleshooting mbuild

Troubleshooting the Compiler

Coding with M-Files Only

Alternative Ways of Compiling M-Files

Compiling MATLAB Provided M-Files Separately

Compiling mrank.m and rank.m as Helper Functions

Mixing M-Files and C or C++

Simple Example

Advanced C Example

Controlling
Code Generation

Code Generation Overview

Example M-Files

Generated Code

Compiling Private and Method Functions

The Generated Header Files

C Header File

C++ Header File

Internal Interface Functions

C Interface Functions

C++ Interface Functions

Supported Executable Types

Generating Files

MEX-Files

Main Files

Simulink S-Functions

C Libraries

C Shared Library

C++ Libraries

Porting Generated Code to a Different Platform

Formatting Compiler-Generated Code

Listing All Formatting Options

Setting Page Width

Setting Indentation Spacing

Including M-File Information in Compiler Output

Controlling Comments in Output Code

Controlling #line Directives in Output Code

Controlling Information in Run-Time Errors

Interfacing M-Code to C/C++ Code

C Example

Using Pragmas

Print Handlers

Main Routine Written in C

Main Routine Written in M-Code

Optimizing Performance

Optimization Bundles

Optimizing Arrays

Scalar Arrays

Nonscalar Arrays

Optimizing Loops

Simple Indexing

Loop Simplification

Optimizing Conditionals

Reference


Reference

Pragmas

%#external

%#function

%#mex

Functions

mbchar

mbcharscalar

mbcharvector

mbint

mbintscalar

mbintvector

mbreal

mbrealscalar

mbrealvector

mbscalar

mbvector

reallog

realpow

realsqrt

Command Line Tools

mbuild

mcc

MATLAB Compiler Option Flags

MATLAB Compiler
Quick Reference

Common Uses of the Compiler

mcc

Error and Warning Messages

Compile-Time Errors

Warning Messages

Run-Time Errors


 Getting Started