Skip to Main Content Skip to Search
Product Documentation

fopen - Connect interface object to instrument

Syntax

fopen(obj)

Arguments

obj

An interface object or an array of interface objects.

Description

fopen(obj) connects obj to the instrument.

Tips

Before you can perform a read or write operation, obj must be connected to the instrument with the fopen function. When obj is connected to the instrument

An error is returned if you attempt to perform a read or write operation while obj is not connected to the instrument. You can connect only one interface object to a given instrument. For example, on a Windows machine you can connect only one serial port object to an instrument associated with the COM1 port. Similarly, you can connect only one GPIB object to an instrument with a given board index, primary address, and secondary address.

Some properties are read-only while the interface object is connected, and must be configured before using fopen. Examples include InputBufferSize and OutputBufferSize. Refer to the property reference pages or use the propinfo function to determine which properties have this constraint.

The values for some properties are verified only after obj is connected to the instrument. If any of these properties are incorrectly configured, an error is returned when fopen is issued and obj is not connected to the instrument. Properties of this type include BaudRate and SecondaryAddress, and are associated with instrument settings.

Examples

This example creates the GPIB object g, connects g to the instrument using fopen, writes and reads text data, and then disconnects g from the instrument.

g = gpib('ni',0,1);
fopen(g)
fprintf(g,'*IDN?')
idn = fscanf(g);
fclose(g)

See Also

BytesAvailable | BytesToOutput | fclose | instrhelp | propinfo | Status | ValuesReceived | ValuesSent

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS