External Interfaces/API    

Calling C and Fortran Programs from MATLAB

Introducing MEX-Files

Using MEX-Files

The Distinction Between mx and mex Prefixes

MATLAB Data

The MATLAB Array

Data Storage

Data Types in MATLAB

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

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

Masking Floating-Point Exceptions

Compiling and Linking on UNIX

Compiling and Linking on Windows

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

Bringing Java Classes into MATLAB

Sources of Java Classes

Defining New Java Classes

Making Java Classes Available to MATLAB

Loading Java Class Definitions

Simplifying Java Class Names

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

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

Importing and Exporting Data

Using MAT-Files

Importing Data to MATLAB

Exporting Data from MATLAB

Exchanging Data Files Between Platforms

Reading and Writing MAT-Files

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

COM and DDE Support

Introducing MATLAB COM Integration

Concepts and Terminology

Overview of MATLAB COM Support

MATLAB COM Client Support

Creating COM Objects

Object Properties

Invoking Methods

COM Control Events

Identifying Objects

Saving Your Work

Releasing COM Interfaces and Objects

Writing Event Handlers

Examples of MATLAB as an Automation Client

Additional COM Client Information

Using COM Collections

Converting Data

Using MATLAB as a DCOM Server Client

MATLAB COM Support Limitations

MATLAB Automation Server Support

MATLAB COM Automation Methods

MATLAB Automation Properties

Additional Automation Server Information

Launching the MATLAB Server

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

DDE Advisory Links

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


  External Interfaces/API Calling C and Fortran Programs from MATLAB