Reputation: 6323
given:
v = textread(strPathFilename, '%s', 'delimiter', ' ', 'endofline', '\r\n');
I want returned 'v' as a cellArray of columns from the file.
but instead I get 1 column of everything parsed by a space.
Desired:
file:
1 2 3 4 CR
5 6 7 8 CR
9 10 11 12 CR
v{1}:
1, 5, 9
v{2}:
2, 6, 10
Upvotes: 0
Views: 70
Reputation: 2750
How about this:
C = textscan(fid,'%f %f %f %f %s','Delimiter','\n');
I hope this helps.
Upvotes: 0
Reputation: 9317
You can use textscan
to achieve this:
fid = fopen(strPathFilename,'r')
v = textscan(fid, '%d%d%d%d', 'delimiter', ' ', 'endofline', '\r\n')
fclose(fid)
This results in
v =
[3x1 int32] [3x1 int32] [3x1 int32] [3x1 int32]
with each of the cells containing one column.
Upvotes: 1