Leer datos con formato HH:MM:SS AM/PM de un archivo de texto y usarlos como eje X en una gráfica
Publicado por Isabel (1 intervención) el 30/10/2014 21:27:06
Hola, estoy intentando extraer los datos de un archivo de texto para dibujar gráficas en función del tiempo. El archivo de texto es algo así:
FILE NAME: DEFAULT1_2013-02-13_09-00-54.txt
DATE: Wednesday, February 13, 2013
TIME: 9:00:54 AM
CH01: PV O2 (ml/min)
CH02: PV H2 (ml/min)
CH03: PV CO2 (ml/min)
CH04: PV CO (ml/min)
CH05: PV CH4 (ml/min)
CH06: PV N2 (ml/min)
CH07: PV CEM GAS CARRIER (ml/min)
CH08: PV CEM LIQUID (g/h)
CH09: PV REACTOR TEMPERATURE (ºC)
CH10: PV CEM TEMPERATURE (ºC)
CH11: PV PRESSURE (bar)
SAMPLE TIME CH01 CH02 CH03 CH04 CH05 CH06 CH07 CH08 CH09 CH10 CH11
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
000000 9:00:53 AM +0000 +0000 +0000 +0000 +0000 +0000 +0587 +0.03 +0798 +0196 +3.7
000001 9:00:54 AM +0000 +0000 +0000 +0000 +0000 +0000 +0587 +0.03 +0798 +0196 +3.7
000002 9:00:55 AM +0000 +0000 +0000 +0000 +0000 +0000 +0586 +0.03 +0799 +0196 +3.7
000003 9:00:56 AM +0000 +0000 +0000 +0000 +0000 +0000 +0587 +0.02 +0799 +0196 +3.7
000004 9:00:57 AM +0000 +0000 +0000 +0000 +0000 +0000 +0587 +0.02 +0800 +0196 +3.7
000005 9:00:58 AM +0000 +0000 +0000 +0000 +0000 +0000 +0587 +0.02 +0800 +0196 +3.7
He intentado varias cosas:
>> Datos=load('DEFAULT1_2013-02-13_09-00-54.txt')
??? Error using ==> load
Number of columns on line 1 of ASCII file
D:\Trabajo\DEFAULT1_2013-02-13_09-00-54.txt
must be the same as previous lines.
>> Datos=dlmread('DEFAULT1_2013-02-13_09-00-54.txt','\t',38)
Warning: Obsolete syntax. C must be specified with R.
> In dlmread at 88
??? Error using ==> dlmread at 145
Mismatch between file and format string.
Trouble reading number from file (row 1, field 3) ==>
:01:0
Error in ==> dlmread at 90
result= dlmread(filename,delimiter,r,0);
Al final he conseguido extraer los datos con importdata. El problema es que como ahora la columna de la hora la ha guardado como texto cuando intento hacer una gráfica de la temperatura frente a la hora me da un error.
Datos=importdata('DEFAULT1_2013-02-13_09-00-54.txt')
Datos =
data: [26691x21 double]
textdata: {26719x2 cell}
>> Hora=Datos.textdata(19:end,2);
>> Temperatura=Datos.data(:,9);
>> figure,plot(Hora,Temperatura)
??? Error using ==> plot
Conversion to double from cell is not possible.
Soy novata usando Matlab así que agradecería vuestra ayuda.
Muchas gracias.
Isabel
FILE NAME: DEFAULT1_2013-02-13_09-00-54.txt
DATE: Wednesday, February 13, 2013
TIME: 9:00:54 AM
CH01: PV O2 (ml/min)
CH02: PV H2 (ml/min)
CH03: PV CO2 (ml/min)
CH04: PV CO (ml/min)
CH05: PV CH4 (ml/min)
CH06: PV N2 (ml/min)
CH07: PV CEM GAS CARRIER (ml/min)
CH08: PV CEM LIQUID (g/h)
CH09: PV REACTOR TEMPERATURE (ºC)
CH10: PV CEM TEMPERATURE (ºC)
CH11: PV PRESSURE (bar)
SAMPLE TIME CH01 CH02 CH03 CH04 CH05 CH06 CH07 CH08 CH09 CH10 CH11
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
000000 9:00:53 AM +0000 +0000 +0000 +0000 +0000 +0000 +0587 +0.03 +0798 +0196 +3.7
000001 9:00:54 AM +0000 +0000 +0000 +0000 +0000 +0000 +0587 +0.03 +0798 +0196 +3.7
000002 9:00:55 AM +0000 +0000 +0000 +0000 +0000 +0000 +0586 +0.03 +0799 +0196 +3.7
000003 9:00:56 AM +0000 +0000 +0000 +0000 +0000 +0000 +0587 +0.02 +0799 +0196 +3.7
000004 9:00:57 AM +0000 +0000 +0000 +0000 +0000 +0000 +0587 +0.02 +0800 +0196 +3.7
000005 9:00:58 AM +0000 +0000 +0000 +0000 +0000 +0000 +0587 +0.02 +0800 +0196 +3.7
He intentado varias cosas:
>> Datos=load('DEFAULT1_2013-02-13_09-00-54.txt')
??? Error using ==> load
Number of columns on line 1 of ASCII file
D:\Trabajo\DEFAULT1_2013-02-13_09-00-54.txt
must be the same as previous lines.
>> Datos=dlmread('DEFAULT1_2013-02-13_09-00-54.txt','\t',38)
Warning: Obsolete syntax. C must be specified with R.
> In dlmread at 88
??? Error using ==> dlmread at 145
Mismatch between file and format string.
Trouble reading number from file (row 1, field 3) ==>
:01:0
Error in ==> dlmread at 90
result= dlmread(filename,delimiter,r,0);
Al final he conseguido extraer los datos con importdata. El problema es que como ahora la columna de la hora la ha guardado como texto cuando intento hacer una gráfica de la temperatura frente a la hora me da un error.
Datos=importdata('DEFAULT1_2013-02-13_09-00-54.txt')
Datos =
data: [26691x21 double]
textdata: {26719x2 cell}
>> Hora=Datos.textdata(19:end,2);
>> Temperatura=Datos.data(:,9);
>> figure,plot(Hora,Temperatura)
??? Error using ==> plot
Conversion to double from cell is not possible.
Soy novata usando Matlab así que agradecería vuestra ayuda.
Muchas gracias.
Isabel
Valora esta pregunta


0