How to read from a serial port in Matlab R2018a
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I need to read and save the input data from a USB port. As I searched, first the serial port, as an object, should be defined:
- serialport (MatLab 2019 and later)
- serial (MatLab 2018 and older)
Then, using the "read" function, the port can be read. Although, the "read" function does not work for "serial":
- Undefined function 'read' for input arguments of type 'serial'.
How could I read the input data from a USB port in MatLab 2018a?
0 Kommentare
Antworten (1)
jq rq
am 12 Nov. 2020
Hi Shahin,
I've found something that works for me using older commands in R2019a.
Let's assume device like multimeter where we know port (or we can detect it), baudrate and we're periodically sending there command like tell me value, output is string (char).
clc; clear; close all
s = serial('COM3','BaudRate',230400);
fopen(s)
for i = 1:11
fprintf(s,"VAL?")
pause(1)
fgets(s) % <- output
end
fclose(s)
Hope this helped you!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!