(To be removed) Write text to device
fprintf(obj,'cmd') writes the string
cmd to the device connected to the serial port object,
obj. The default format is
write operation is synchronous and blocks the command line until execution
cmd can be either a SCPI command you provide, or
a command you provide based on instructions from your device vendor.
writes the string using the format specified by
writes the string with command-line access specified by
cmd is written synchronously or asynchronously.
writes the string using the specified format.
a C language conversion specification.
You need an open connection from the serial port object,
to the device before performing read or write operations.
To open a connection to the device, use the
obj has an open connection to the device, it has a
Status property value of
Specifies the string
Specifies whether the string
If you specify asynchronous
To determine whether an asynchronous write operation is in
progress, use the
Create a serial port object
s and connect it to a
Tektronix TDS 210 oscilloscope. Write the
RS232? instructs the
scope to return serial port communications settings. This example works on a
s = serial('COM1'); fopen(s) fprintf(s,'RS232?')
Specify a format for the data that does not include the terminator, or configure the terminator to empty.
s = serial('COM1'); fopen(s) fprintf(s,'%s','RS232?')
The default format for
%s\n. Therefore, the terminator specified by the
Terminator property is automatically written.
However, sometimes you might want to suppress writing the terminator.
Specify an array of formats and commands:
s = serial('COM1'); fopen(s) fprintf(s,['ch:%d scale:%d'],[1 20e-3],'sync')
Version HistoryIntroduced before R2006a
serial object interface will be removed
Not recommended starting in R2021a
Use of this function with a
serial object will be removed. To access a
serial port device, use a
serialport object with its functions and properties
The recommended functionality has additional capabilities and improved performance. See Transition Your Code to serialport Interface for more information about using the recommended functionality.