필터 지우기
필터 지우기

How to read Value from .txt

조회 수: 1 (최근 30일)
Arun Kumar Singh
Arun Kumar Singh 2020년 6월 15일
댓글: Arun Kumar Singh 2020년 6월 15일
Here i am attaching screenshot of my file which is in .txt format, i have to read the three values (Marked in the screenshot) from the file. Could you please help me in this ??
  댓글 수: 6
Walter Roberson
Walter Roberson 2020년 6월 15일
편집: Walter Roberson 2020년 6월 15일
fopen(), textscan() with headerlines 2, format '%*s%f%f%f', 'collectoutput', true, and count 1 (the count goes immediately after the format and before any other options.) cell2mat() the result of textscan() to get the numeric data. fclose()
Arun Kumar Singh
Arun Kumar Singh 2020년 6월 15일
could you please write the proper code because i am new for matlab .

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 6월 15일
filename = 'File.txt';
fid = fopen(filename, 'rt');
GAL = cell2mat(textscan(fid, '%*s%f%f%f', 1, 'headerlines', 2, 'collectoutput', true));
fclose(fid);
  댓글 수: 1
Arun Kumar Singh
Arun Kumar Singh 2020년 6월 15일
Thank you sir, it worked ...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by