Hourly Averaging over 10s Data
4 ビュー (過去 30 日間)
古いコメントを表示
I have 10 second data in an excel file. I have opened it will xlsread. The first column is the date and time, which I have converted to a datenumber using datenum(). Now I would like to take an hourly average of data using unique() and accumarray(), which I have used before but I had some help so I'm having difficulty modifying my previous code to work with this particular file. I need help doing this. To begin with I'm having the error:
Error using cell/unique (line 85)
Input A must be a cell array of strings.
I know it can be used with doubles, so I'm not sure what the issue is here. Maybe the issue is that these are in cells so maybe I need to convert every cell to an array but that seems like that could be avoided.
I've included my code below. The data is now like
{datanum} {incorrect date that I need to toss out} {25 columns of data} {three column of data which I need to throw out}
filenameexl = ('June2014Neph_Count_SD_Filtered_Trial');
[ndata, text, alldata] = xlsread(filenameexl)
datetime = alldata(:,1);
formatIn = ('mm/dd/yyyy HH:MM:SS AM');
%Calculating first day of the year to subtract
dayone2014 = ('01/01/2014 12:00:00 AM');
P = datenum(dayone2014,formatIn);
PP = datenum(datetime,formatIn);
%final datenumber to be used
datenumberfinal = num2cell(PP-P);
alldata(:,1) = datenumberfinal;
[u,~,ix] = unique(alldata(:,1),'rows');
I need some help here.
1 件のコメント
dpb
2015 年 2 月 2 日
The 'rows' option only works for cells of strings or numeric. You're only wanting the unique values for the column any way so it's superfluous here; drop it.
I'd convert to arrays out of cells on general principles anyway; there's no need of a cell array here once you've converted a datastring to datenumber.
採用された回答
Chad Greene
2015 年 2 月 2 日
It's hard to see what exactly is going on because we don't have your source data and your variable names are not intuitive.
[y_hourly,t_hourly] = downsample_ts(y,t,'hourly','mean');
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!