Why does the TEXTREAD function not read any empty fields at the end of a file within MATLAB?

4 次查看(过去 30 天)
Why does the TEXTREAD function not read any empty fields at the end of a file within MATLAB?
My text file has several lines or rows of data containing a specific number of fields (groups of characters or numbers, that could, for instance, be tab delimited). When the last few fields at the end of my file are empty, the TEXTREAD function does not read them.
For example, I have a file called myfile.txt which contains three fields. I use TEXTREAD to read from the file, as follows:
[a, b, c] = textread('myfile.txt','%s %s %s ','delimiter','\t');
length(a)
length(b)
length(c)
If the last line of myfile.txt contains empty values for the second and third fields, then TEXTREAD does not assign them to variables "b" and "c".

采纳的回答

MathWorks Support Team
This has been verified as a bug in MATLAB 6.5.1 (R13SP1) in the way that the TEXTREAD function reads empty fields from a file.
Currently, to work around this issue, please insert a line break at the end of your file by pressing the "RETURN" or "ENTER" key.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息

产品


版本

R13SP1

Community Treasure Hunt

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

Start Hunting!

Translated by