| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → xPC Target |
| Contents | Index |
| Learn more about xPC Target |
This chapter describes how to write a custom application using the xPC Target COM API. This COM API enables you to write COM applications to load, run, and control an xPC Target application.
Before you start, read this section for guidelines on writing custom applications based on the xPC Target COM API. You do not need to be a seasoned C or C++ programmer to follow the procedures in this chapter, or to write custom applications with the xPC Target COM API. You should, however, have some rudimentary programming knowledge.
This chapter provides procedures on how to create xPC Target COM API applications using Microsoft Visual Basic®:
The procedures in this example use the model xpctank.mdl. If you want to rebuild this model, or otherwise use the MATLAB software, you must have xPC Target software version 2.0 or higher.
To determine which version of the software you are currently using, at the MATLAB command line, type
xpclib
This opens the xPC Target Simulink blocks library. The xPC Target software version of should be at the bottom of the window.
You can work with xPC Target applications with either the MATLAB software or an xPC Target COM API application. If you are working with an xPC Target application using an xPC Target COM API application simultaneously with a MATLAB session interacting with the target, keep in mind that only one application can access the target PC at a time. To move from the MATLAB session to your application, in the MATLAB Command Window, type
close(xpc)
This frees the connection to the target PC for use by your xPC Target COM API application. Conversely, you will need to have your COM API application call the Close method to enable access to the target from a MATLAB session.
Although you are building an xPC Target COM API application, you still need to access the xpcapi.dll. When distributing the xPC Target COM API application, place this file in one of the following, in order of preference:
Directory from which application is loaded
Windows® system directory
![]() | xPC Target COM API | Example Visual Basic GUI Using COM Objects | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |