How to read only numerical values of serial output data in MATLAB?

2 vues (au cours des 30 derniers jours)
I just want to read the integer values (number) in the output text file (serial data)...... I need some assistance.....

Réponse acceptée

Walter Roberson
Walter Roberson le 8 Nov 2021
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/791754/Log_file.txt';
data = readmatrix(filename, 'Range', 'C:C')
data = 10×1
1562 2027 363 2808 2770 5947 3477 340 1131 2775

Plus de réponses (2)

Yongjian Feng
Yongjian Feng le 6 Nov 2021
Your data file looks like a configuration file with key/value pair separated by ':'. One way to parse the data is to do this for each row:
rowStr = 'ADC0/F1 : 1562';
tokens = split(rowStr, ':');
intValue = str2double(strtrim(tokens(2)));
  1 commentaire
Sohail Ahmed
Sohail Ahmed le 8 Nov 2021
Modifié(e) : Sohail Ahmed le 8 Nov 2021
Great. But I just want the code to read all integer values at once.

Connectez-vous pour commenter.


Sohail Ahmed
Sohail Ahmed le 10 Nov 2021
Thanks....... It worked.
  1 commentaire
Walter Roberson
Walter Roberson le 10 Nov 2021
Please remember to Accept the solution that worked for you.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by