Specifying Delimiter and Empty Value Conversion
Using a text editor, create a comma-delimited file data.csv that contains
1, 2, 3, 4, , 6
7, 8, 9, , 11, 12
Read the file, converting empty cells to -Inf:
fid = fopen('data.csv');
C = textscan(fid, '%f %f %f %f %u32 %f', 'delimiter', ',','EmptyValue', -Inf);
fclose(fid);
textscan returns a 1-by-6 cell array C with the following cells:
C{1} = [1; 7] class double
C{2} = [2; 8] class double
C{3} = [3; 9] class double
C{4} = [4; -Inf] class double (empty converted to -Inf)
C{5} = [0; 11] class uint32 (empty converted to 0)
C{6} = [6; 12] class double
Using a text editor, create a comma-delimited file data.csv that contains
1, 2, 3, 4, , 6
7, 8, 9, , 11, 12
Read the file, converting empty cells to -Inf:
fid = fopen('data.csv');
C = textscan(fid, '%f %f %f %f %u32 %f', 'delimiter', ',','EmptyValue', -Inf);
fclose(fid);
textscan returns a 1-by-6 cell array C with the following cells:
C{1} = [1; 7] class double
C{2} = [2; 8] class double
C{3} = [3; 9] class double
C{4} = [4; -Inf] class double (empty converted to -Inf)
C{5} = [0; 11] class uint32 (empty converted to 0)
C{6} = [6; 12] class double