필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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.

카테고리

Help CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by