Reputation: 495
I am trying to read a csv file use textscan. The fields are seperated with ',' . I used the following code, but it only read in one line of data into the matrix W.
I also tried dlmread(), it got the number of fields wrong.
The file is contructed under linux, matlab is under linux.
file_id = fopen('H:\data\overlapmatrices\cos.mat.10');
W = textscan(file_id, '%f', 'delimiter', ',' , 'EndOfLine', '\r\n');
fclose(file_id);
clear file_id;
Upvotes: 0
Views: 4134
Reputation: 13558
The problem could be in how the end of line is represented in the file (see also this article on Wikipedia). While \r\n
(the combination of a carriage return and a newline character) is common on Windows, \n
(just the newline character) is the standard on Linux and other Unix systems.
But as ben is saying, csvread
might be an easier way how to read the file.
Upvotes: 1