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

2 ビュー (過去 30 日間)
Sohail Ahmed
Sohail Ahmed 2021 年 11 月 6 日
コメント済み: Walter Roberson 2021 年 11 月 10 日
I just want to read the integer values (number) in the output text file (serial data)...... I need some assistance.....

採用された回答

Walter Roberson
Walter Roberson 2021 年 11 月 8 日
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

その他の回答 (2 件)

Yongjian Feng
Yongjian Feng 2021 年 11 月 6 日
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 件のコメント
Sohail Ahmed
Sohail Ahmed 2021 年 11 月 8 日
編集済み: Sohail Ahmed 2021 年 11 月 8 日
Great. But I just want the code to read all integer values at once.

サインインしてコメントする。


Sohail Ahmed
Sohail Ahmed 2021 年 11 月 10 日
Thanks....... It worked.
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 11 月 10 日
Please remember to Accept the solution that worked for you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by