Problem Reading Data from .txt File with textscan.
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi all, I'm facing problems reading .txt files.(attached file) I'd like to skip the first 4 rows and continue reading the data. The first column is the date and time string, after that is the measurement data. The problem is probably with the formatSpec parameter. Any help is more than welcome.
Here is my code:
N=10;
fid = fopen('Test_file.txt','r');
formatSpec = '%s %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f';
[indata, position] = textscan(fid,formatSpec,N,'HeaderLines',4,'Delimiter','\t');
fclose(fid);
0 comentarios
Respuesta aceptada
ES
el 14 de Mzo. de 2017
Editada: ES
el 14 de Mzo. de 2017
When I open your txt file, i find a lot of spaces even between the digits of a floating number [example try opening it in MATLAB editor]. So they could only be read using format specifier of %s and not %f. Please check your input file. May be this is because of unicode encoding.
I changed the encoding to ANSI (notepad->file->save as ) and I was able to run your script without any issue.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Other Formats en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!