Download MATLAB Compiler User`s Guide

Transcript
Coding with M-Files Only . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33
Alternative Ways of Compiling M-Files . . . . . . . . . . . . . . . . . . . 4-37
Compiling MATLAB-Provided M-Files Separately . . . . . . . . . 4-37
Compiling mrank.m and rank.m as Helper Functions . . . . . . 4-38
Mixing M-Files and C or C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Simple Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
mrank.m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
The Build Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
mrankp.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
An Explanation of mrankp.c . . . . . . . . . . . . . . . . . . . . . . . . .
Advanced C Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
An Explanation of This C Code . . . . . . . . . . . . . . . . . . . . . . .
Advanced C++ Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Algorithm for the Example . . . . . . . . . . . . . . . . . . . . . . . . . .
M-Files for the Example . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Building the Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Running the Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Compiler-Generated C++ Files . . . . . . . . . . . . . . . . . . . . . . .
The Generated Main C++ Routine . . . . . . . . . . . . . . . . . . . .
C++ Functions Generated from each M-file Function . . . . .
The Generated Mf Implementation Function . . . . . . . . . . .
The Generated F Interface Function . . . . . . . . . . . . . . . . . .
The Generated mlxF Interface Function . . . . . . . . . . . . . . .
4-39
4-39
4-39
4-40
4-42
4-43
4-44
4-46
4-47
4-48
4-48
4-48
4-49
4-49
4-50
4-51
4-51
4-53
4-55
Controlling Code Generation
5
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example M-Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Sierpinski Gasket M-File . . . . . . . . . . . . . . . . . . . . . . . . . . . .
foo M-File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
fun M-File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
sample M-File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Generated Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
vi
Contents
5-2
5-3
5-3
5-3
5-4
5-4
5-4