This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Record data and event information to file




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.


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');
s.RecordDetail = 'verbose';
s.RecordName = 'MySerialFile.txt';
out = fscanf(s);


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.

Introduced before R2006a