External Interfaces Previous page   Next Page

Examples of a MATLAB Automation Server

This section provides code examples that show you how to access a MATLAB automation server from Visual Basic and C#.

Example -- Running an M-File from Visual Basic

This example calls an M-file function named solve_bvp from a Visual Basic client application through a COM interface. It also plots a graph in a new MATLAB window and performs a simple computation:

Example -- Viewing Methods from a Visual Basic 6.0 Client

You can find out what methods are available from a MATLAB automation server using the Object Browser of your Visual Basic client application. To do this, follow this procedure in the client application to reference the MATLAB Application Type Library:

  1. Select the Project menu
  2. Select Reference from the subsequent menu
  3. Check the box next to the MATLAB Application Type Library
  4. Click OK

This enables you to view MATLAB automation methods from the Visual Basic Object Browser under the Library called MLAPP. You will now also be able to see a list of MATLAB automation methods when you use the term Matlab followed by a period. For example,

Example -- Calling MATLAB from a C# Client

This example simply creates data in the client C# program and passes it to MATLAB. The matrix (containing complex data) is then passed back to the C# program.

Note that the reference to the MATLAB Type Library for C# is:

Here is the complete example.


Previous page  Automation Server Functions MATLAB Automation Properties Next page

© 1994-2005 The MathWorks, Inc.