Using MAT-Files
Importing Data to MATLAB
Exporting Data from MATLAB
Exchanging Data Files Between Platforms
Reading and Writing MAT-Files
Writing Character Data
Finding Associated Files
Examples of MAT-Files
Creating a MAT-File in C
Reading a MAT-File in C
Creating a MAT-File in Fortran
Reading a MAT-File in Fortran
Compiling and Linking MAT-File Programs
Masking Floating Point Exceptions
Compiling and Linking on UNIX
Compiling and Linking on Windows
Required Files from Third-Party Sources
Working Directly with Unicode
MATLAB Interface to Generic DLLs
Overview
Loading and Unloading the Library
Loading the Library
Unloading the Library
Getting Information About the Library
Invoking Library Functions
Passing Arguments
Some General Rules
Passing References
Data Conversion
Primitive Types
Enumerated Types
Structures
Creating References
Reference Pointers
Calling C and Fortran Programs from MATLAB
Introducing MEX-Files
Using MEX-Files
MEX-File Placement
The Distinction Between mx and mex Prefixes
MATLAB Data
The MATLAB Array
Data Storage
Data Types in MATLAB
Sparse Matrices
Using Data Types
Building MEX-Files
Compiler Requirements
Testing Your Configuration on UNIX
Testing Your Configuration on Windows
Specifying an Options File
Custom Building MEX-Files
Who Should Read this Chapter
MEX Script Switches
Default Options File on UNIX
Default Options File on Windows
Custom Building on UNIX
Custom Building on Windows
Troubleshooting
Configuration Issues
Understanding MEX-File Problems
Compiler and Platform-Specific Issues
Memory Management Compatibility Issues
Additional Information
Files and Directories - UNIX Systems
Files and Directories - Windows Systems
Examples
Technical Support
Creating C Language MEX-Files
C MEX-Files
The Components of a C MEX-File
Required Arguments to a MEX-File
Examples of C MEX-Files
A First Example -- Passing a Scalar
Passing Strings
Passing Two or More Inputs or Outputs
Passing Structures and Cell Arrays
Handling Complex Data
Handling 8-,16-, and 32-Bit Data
Manipulating Multidimensional Numerical Arrays
Handling Sparse Arrays
Calling Functions from C MEX-Files
Advanced Topics
Help Files
Linking Multiple Files
Workspace for MEX-File Functions
Memory Management
Large File I/O
Using LAPACK and BLAS Functions
Debugging C Language MEX-Files
Debugging on UNIX
Debugging on Windows
Creating Fortran MEX-Files
Fortran MEX-Files
The Components of a Fortran MEX-File
The %val Construct
Examples of Fortran MEX-Files
A First Example -- Passing a Scalar
Passing Strings
Passing Arrays of Strings
Passing Matrices
Passing Two or More Inputs or Outputs
Handling Complex Data
Dynamically Allocating Memory
Handling Sparse Matrices
Calling Functions from Fortran MEX-Files
Advanced Topics
Help Files
Linking Multiple Files
Workspace for MEX-File Functions
Memory Management
Debugging Fortran Language MEX-Files
Debugging on UNIX
Debugging on Windows
Calling MATLAB from C and Fortran Programs
Using the MATLAB Engine
The Engine Library
GUI-Intensive Applications
Examples of Calling Engine Functions
Calling MATLAB from a C Application
Calling MATLAB from a Fortran Application
Attaching to an Existing MATLAB Session
Compiling and Linking Engine Programs
Step 1 -- Write Your Application
Step 2 -- Check Required Libraries and Files
Step 3 -- Build the Application
Step 4 -- Set Run-time Library Path
Step 5 -- (Windows Only) Register MATLAB As a COM Server
Step 6 -- Test Out the Program
Example -- Building an Engine Application on UNIX
Example -- Building an Engine Application on Windows
Masking Floating-Point Exceptions
Calling Java from MATLAB
Using Java from MATLAB: An Overview
Java Interface Is Integral to MATLAB
Benefits of the MATLAB Java Interface
Who Should Use the MATLAB Java Interface
To Learn More About Java Programming
Platform Support for the Java Virtual Machine
Using a Different Version of the Java JVM
Bringing Java Classes and Methods into MATLAB
Sources of Java Classes
Defining New Java Classes
The Java Class Path
Making Java Classes Available to MATLAB
Loading Java Class Definitions
Simplifying Java Class Names
Locating Native Method Libraries
Creating and Using Java Objects
Constructing Java Objects
Concatenating Java Objects
Saving and Loading Java Objects to MAT-Files
Finding the Public Data Fields of an Object
Accessing Private and Public Data
Determining the Class of an Object
Invoking Methods on Java Objects
Using Java and MATLAB Calling Syntax
Invoking Static Methods on Java Classes
Obtaining Information About Methods
Java Methods That Affect MATLAB Commands
How MATLAB Handles Undefined Methods
How MATLAB Handles Java Exceptions
Working with Java Arrays
How MATLAB Represents the Java Array
Creating an Array of Objects Within MATLAB
Accessing Elements of a Java Array
Assigning to a Java Array
Concatenating Java Arrays
Creating a New Array Reference
Creating a Copy of a Java Array
Passing Data to a Java Method
Conversion of MATLAB Argument Data
Passing Built-In Data Types
Passing String Arguments
Passing Java Objects
Other Data Conversion Topics
Passing Data to Overloaded Methods
Handling Data Returned from a Java Method
Conversion of Java Return Data
Built-In Data Types
Java Objects
Converting Objects to MATLAB Data Types
Introduction to Programming Examples
Example - Reading a URL
Description of URLdemo
Running the Example
Example - Finding an Internet Protocol Address
Description of resolveip
Running the Example
Example - Communicating Through a Serial Port
Setting Up the Java Environment
Description of Serial Example
Running the serialexample Program
Example - Creating and Using a Phone Book
Description of Function phonebook
Description of Function pb_lookup
Description of Function pb_add
Description of Function pb_remove
Description of Function pb_change
Description of Function pb_listall
Description of Function pb_display
Description of Function pb_keyfilter
Running the phonebook Program
COM and DDE Support (Windows Only)
Introducing MATLAB COM Integration
Concepts and Terminology
Supported Client/Server Configurations
Registering Controls and Servers
MATLAB COM Client Support
Creating the Server Process -- an Overview
Creating an ActiveX Control
Instantiating a DLL Component
Instantiating an EXE Component
Getting Interfaces to the Object
Invoking Commands on a COM Object
Identifying Objects and Interfaces
Invoking Methods
Object Properties
Control and Server Events
Writing Event Handlers
Saving Your Work
Releasing COM Interfaces and Objects
Identifying Objects
Examples of MATLAB as an Automation Client
Additional COM Client Information
Using COM Collections
Converting Data
Using MATLAB as a DCOM Client
MATLAB COM Support Limitations
MATLAB Automation Server Support
Creating the Automation Server
Connecting to an Existing Server
Automation Server Functions
Examples of a MATLAB Automation Server
Example -- Running an M-File from Visual Basic
Example -- Viewing Methods from a Visual Basic 6.0 Client
Example -- Calling MATLAB from a C# Client
MATLAB Automation Properties
Additional Automation Server Information
Creating the Server Manually
Specifying a Shared or Dedicated Server
Using MATLAB as a DCOM Server
Dynamic Data Exchange (DDE)
DDE Concepts and Terminology
Accessing MATLAB as a Server
The DDE Name Hierarchy
Example -- Using Visual Basic and the MATLAB DDE Server
Using MATLAB as a Client
Example -- Importing Data From an Excel Application
DDE Advisory Links
Web Services in MATLAB
What Are Web Services in MATLAB?
Understanding Data Type Conversions
Finding More Information About Web Services
Using Web Services in MATLAB
Building MATLAB Applications with Web Services
Understanding Web Service Limitations
Programming with Web Services
Simple M-File Example
Serial Port I/O
Introduction
What Is the MATLAB Serial Port Interface?
Supported Serial Port Interface Standards
Supported Platforms
Using the Examples with Your Device
Overview of the Serial Port
What Is Serial Communication?
The Serial Port Interface Standard
Connecting Two Devices with a Serial Cable
Serial Port Signals and Pin Assignments
Serial Data Format
Finding Serial Port Information for Your Platform
Selected Bibliography
Getting Started with Serial I/O
Example: Getting Started
The Serial Port Session
Configuring and Returning Properties
Creating a Serial Port Object
Configuring Properties During Object Creation
The Serial Port Object Display
Creating an Array of Serial Port Objects
Connecting to the Device
Configuring Communication Settings
Writing and Reading Data
Example: Introduction to Writing and Reading Data
Controlling Access to the MATLAB Command Line
Writing Data
Reading Data
Example: Writing and Reading Text Data
Example: Parsing Input Data Using strread
Example: Reading Binary Data
Events and Callbacks
Example: Introduction to Events and Callbacks
Event Types and Callback Properties
Storing Event Information
Creating and Executing Callback Functions
Enabling Callback Functions After They Error
Example: Using Events and Callbacks
Using Control Pins
Signaling the Presence of Connected Devices
Controlling the Flow of Data: Handshaking
Debugging: Recording Information to Disk
Example: Introduction to Recording Information
Creating Multiple Record Files
Specifying a Filename
The Record File Format
Example: Recording Information to Disk
Saving and Loading
Using Serial Port Objects on Different Platforms
Disconnecting and Cleaning Up
Disconnecting a Serial Port Object
Cleaning Up the MATLAB Environment
Property Reference
The Property Reference Page Format
Serial Port Object Properties
BaudRate
BreakInterruptFcn
ByteOrder
BytesAvailable
BytesAvailableFcn
BytesAvailableFcnCount
BytesAvailableFcnMode
BytesToOutput
DataBits
DataTerminalReady
ErrorFcn
FlowControl
InputBufferSize
Name
OutputBufferSize
OutputEmptyFcn
Parity
PinStatus
PinStatusFcn
Port
ReadAsyncMode
RecordDetail
RecordMode
RecordName
RecordStatus
RequestToSend
Status
StopBits
Tag
Terminator
Timeout
TimerFcn
TimerPeriod
TransferStatus
Type
UserData
ValuesReceived
ValuesSent
Examples