Effacer les filtres
Effacer les filtres

dlmread not working as expected...

3 vues (au cours des 30 derniers jours)
Benson
Benson le 12 Juin 2013
%This is my file (and also the expected output):
%0 0.334 12:54:00 9.3 -54
%0.22 0.592 13:06:00 5.2 -22
%...........................
M = dlmread(filename.txt);
disp(M);
My current code does not display the expected output.
I have also tried M = dlmread(filename.txt,' '); to specify space delimiters but it returns an error "Mismatch between file and format string. Trouble reading number from file (row 1, field 4) ==> :54:0"
I believe all my values are numeric, since disp(class(12:54:00)) and disp(class(13:06:00)) returns double. Not sure why dlmread doesn't work :(
Any help is appreciated. Thanks!

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 12 Juin 2013
Modifié(e) : Azzi Abdelmalek le 12 Juin 2013
12:54:00 is double because it represent an empty array starting from 12 to 00 with step=54. type
a=12:54:00
I suggest that you use textscan or fgetl to read your data
fid=fopen('YourFileName.txt')
a=textscan(fid,'%f%f%s%f%f')
fclose(fid)

Plus de réponses (0)

Catégories

En savoir plus sur Text Data Preparation dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by