Main Content

record

(To be removed) Record data and event information to file

This serial object function will be removed in a future release. Use serialport object functions instead. For more information on updating your code, see Version History.

Syntax

record(obj)
record(obj,'switch')

Description

record(obj) toggles the recording state for the serial port object, obj.

record(obj,'switch') initiates or terminates recording for obj. switch can be on or off. If switch is on, recording is initiated. If switch is off, recording is terminated.

Examples

This example creates the serial port object s on a Windows® platform. It connects s to the device, configures s to record information to a file, writes and reads text data, and then disconnects s from the device.

s = serial('COM1');
fopen(s)
s.RecordDetail = 'verbose';
s.RecordName = 'MySerialFile.txt';
record(s,'on')
fprintf(s,'*IDN?')
out = fscanf(s);
record(s,'off')
fclose(s)

Tips

Before you can record information to disk, obj must be connected to the device with the fopen function. A connected serial port object has a Status property value of open. An error is returned if you attempt to record information while obj is not connected to the device. Each serial port object must record information to a separate file. Recording is automatically terminated when obj is disconnected from the device with fclose.

The RecordName and RecordMode properties are read-only while obj is recording, and must be configured before using record.

Version History

Introduced before R2006a

collapse all

R2021a: serial object interface will be removed

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 instead.

The recommended functionality has additional capabilities and improved performance. See Transition Your Code to serialport Interface for more information about using the recommended functionality.

See Also

Functions