开发者

MATLAB time stamps reading

开发者 https://www.devze.com 2022-12-28 17:14 出处:网络
Any easy way to read all the co开发者_Python百科lumns in MATLAB? my format is datetimey1y2y3y4 .........................

Any easy way to read all the co开发者_Python百科lumns in MATLAB?

my format is

date  time    y1   y2  y3   y4 .........................      
4/27/2010  00:3:09   34  45  45 56 ................     

so on... Currently i am reading these with the code:

[c,pathc]=uigetfile({'*.txt'},'Select the data','C:\Data');    
file=[pathc c];     
data= dlmread(file, ',', 1,3);    

so needless to say i am skipping the time stamps.

Was wondering if there is easy way to read the time stamps and plot my other columns against the time in hours.

my files are 43200 X 30 and some are 86400 X 90

Related question : is the format same for .csv and .xls files , i mean except of course xlsread


I already answered to your question on the same data here: skip reading headers in MATLAB

[c,pathc]=uigetfile({'*.txt'},'Select the data','C:\Data');
file=[pathc c];
A = importdata(file, ' ', 1);
dt = datenum(A.textdata(2:end,1),'mm/dd/yyyy');
tm = datenum(A.textdata(2:end,2),'HH:MM:SS');
tm = dt+tm-datenum('0:0','HH:MM'); %# combine date and time and correct for zero time.
data = A.data;

You can plot your data against tm and use DATETICK function to show date in any format.

plot(tm,data)
datetick('x','HH')
xlabel('Time, hours')

EDIT

You can also use Jonas's solution for previous question to read the data. Then do same as above:

dt = datenum(dateAndTimeCell(:,1),'mm/dd/yyyy');
tm = datenum(dateAndTimeCell(:,2),'HH:MM:SS');
tm = dt+tm-datenum('0:0','HH:MM');

plot(tm,dataArray,'o-')
datetick('x','HH')
xlabel('Time, hours')


I believe sscanf will do the trick for you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号