Reading .txt file

조회 수: 4 (최근 30일)
jhz
jhz 2020년 1월 9일
답변: Guillaume 2020년 1월 9일
I have a .txt file with 921600 number of digits. I have tried to read this file in Matlab using dlmread and readmatrix functions but both return inf value.
I tried to read the file with uint32 and uint 64 datatypes but they are returning wrong values. I have attached my file with this question, please help.
Thank you.

채택된 답변

Guillaume
Guillaume 2020년 1월 9일
Well, yes you can't read that as a single number. You can either store the whole lot as a vector of digit characters:
digits_text = fileread('digits.txt');
Or convert that to a vector of numbers in the range 0-9:
digits_numeric = digits_text - '0';
Be aware that digits_numeric will use 4 times as much memory as digits_text to store exactly the same information.
You can also store the digits as 8-bit integers (for half the memory of digits_text) but that may hampers you depending on what you want to do with these digits afterwards.
digits_uint8 = uint8(digits_text) - '0';

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by