Hourly Averaging over 10s Data
이전 댓글 표시
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!