Matlab: how to read file using textscan?

I believe all your data are there. If you look inside data every cell there should contains the whole column (10000x1). You can extract i-th cell as an array with data{i} .

Up vote 1 down vote favorite share g+ share fb share tw.

I have a large tab delimited file (10000 rows, 15000 columns) and would like to import it into Matlab. I've tried to import it using textscan function the following way: function C_text, C_data = ReadDataFile(filename, header, attributesCount, delimiter, attributeFormats, attributeFormatCount) AttributeTypes = SetAttributeTypeMatrix(attributeFormats, attributeFormatCount); fid = fopen(filename); if(header == 1) %read column headers C_text = textscan(fid, '%s', attributesCount, 'delimiter', delimiter); C_data = textscan(fid, AttributeTypes{1, 1}, 'headerlines', 1); else C_text = ''; C_data = textscan(fid, AttributeTypes{1, 1}); end fclose(fid); AttributeTypes{1, 1} is a string wich describes variable types for each column (in this case there are 14740 float and 260 string type variables so the value of AttributeTypes{1, 1} is '%f%f......%f%s%s...%s where %f is repeated 14740 times and %s 260 times). When I try to execute >> header, data = ReadDataFile('data/orange_large_train.data.

Chunk1', 1, 15000, '\t', types, size); header array seems to be correct (column names have been read correctly). Data is a 1 x 15000 array (only first row has been imported instead of 10000) and don't know what is causing such behavior. I guess the problem is caused in this line: C_data = textscan(fid, AttributeTypes{1, 1}); but don't know what could be wrong because there is a similar example described in the help reference.

I would be very thankful if anyone of you suggested any fix for the issue - How to read all 10000 rows. Thank you! Matlab data read-file link|improve this question asked Aug 5 '10 at 12:19Niko Gamulin6,5703187136 96% accept rate.

I believe all your data are there. If you look inside data, every cell there should contains the whole column (10000x1). You can extract i-th cell as an array with data{i}.

You would probably want to separate double and string data. I don't know what is attributeFormats, you probably can use this array. But you can also use the AttributeTypes{1, 1}.

Isdouble = strfind(AttributeTypes{1, 1}(2:2:end),'f'); data_double = cell2mat(data(isdouble)); To combine string data into one cell array of strings you can do: isstring = strfind(AttributeTypes{1, 1}(2:2:end),'s'); data_string = horzcat(data{isstring}).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions