Also bare in mind that under column Ch1: the time 42:46.0 represents 5:42:46 PM but I am not sure why Excel automatically displays it as shown in the first post.
How do you load a .csv file, skip lines within it, and plot the values?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi. I seem to have problems loading a .csv file (see attached):
Blah
@Blah
2Blah
Blah
f Blah
fa Blah
Blahasd
Blahasda
vasf Blah
as Blah
asdas Blah
Date Time Ch1:
07/25/2012 42:46.0 96.385
07/25/2012 42:46.0 -177.608
07/25/2012 42:46.0 155.481
07/25/2012 42:46.0 64.15
%Here is my code:
fid = fopen('PULL1.CSV');
% I need to skip the 16 lines. header = textscan(fid, '%s',3,'delimiter', ',',... 'headerLines',16);
data = textscan(fid, '%s %s %s' ,'delimiter', ',');
The problem is that it only recognizes the parameters as strings. Date should be a string. Time should be a floating number. The Ch1 column is a set of values that I want to plot vs. time.
fclose(fid);
Respuesta aceptada
Walter Roberson
el 21 de Sept. de 2012
data_to_plot = str2double(data{3});
15 comentarios
Walter Roberson
el 25 de Sept. de 2012
Use datetick(). You will want to be selective about which time fields you display, as otherwise the tick labels will run into each other.
Más respuestas (1)
per isakson
el 21 de Sept. de 2012
Editada: per isakson
el 21 de Sept. de 2012
Try
data = textscan( fid, '%s%s%f', 'Headerlines', 16 );
Delimiter is obviously one or many "space" or tab. Default handles that.
Ver también
Categorías
Más información sobre Dates and Time en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!