How can I open and read data from a serial port?

3 次查看(过去 30 天)
To open/read pre-recorded data I have previously used:
fileID = fopen('filename.txt', 'rt'); line = fgetl(fileID);
to read the text file line by line. However, I need to be able to read data from an instrument connected to a serial port.
i have used
fid = serial(COMx,baudrate,9600);
fopen(fid);
Will this work for a live instrument?

回答(1 个)

Walter Roberson
Walter Roberson 2016-5-24
fid = serial('COMx', 'baudrate', 9600);
You should also consider setting the Terminiator property.

类别

Help CenterFile Exchange 中查找有关 Instrument Control Toolbox Supported Hardware 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by