3

I'm trying to read a textfile using textscan but I'm having some issues. I found out textscan doesn't read empty values, but I can't get it to work.

I've tried using this, and I even replaced \t with 'space' but it's just returning blank arrays and the only working cell is the first (Data{1,1})

fid = fopen('20150630_ircs_data.txt');
Data = textscan(fid,'%s %s %s %s %s %f %f %s %f %f %f %f %f %s %f %f %f %f %f', 'Delimiter', '\t', 'EmptyValue', 0)
fclose(fid);

The problem is in the empty lines of the 5th row:

enter image description here

File: https://gist.github.com/anonymous/5d9600eb0426e3faaadc

Paulo Maia
  • 63
  • 4

1 Answers1

3

The problem is that you have differents delimiters. 2 "space", 3 "space" ...

So you need to add some delimiters:

Data = textscan(fid,'%s %s %s %s %s %f %f %s %f %f %f %f %f %s %f %f %f %f %f', 'Delimiter',delimiter, 'EmptyValue', 0)

with

delimiter = {'  ','        ','     ','   '};
obchardon
  • 10,614
  • 1
  • 17
  • 33