Octave/MATLAB ‘bug’ with fileread()

data = fileread('in.txt'); data = data(:)';

fixes the problem in Matlab of getting vertical columns of text from some ASCII text files from various operating systems, that is, getting one character per line.

Example

Assume in.txt contains:

Joe 100 eggs

and executing:

data = fileread('in.txt')

gives:

J
o
e
1
0
0
e
g
g
s

Fix

data = data(:)'

gives

Joe100eggs

Leave a Comment