Using @range in timetable when having NaN's

조회 수: 3 (최근 30일)
Robert
Robert 2017년 9월 12일
댓글: Robert 2017년 9월 14일
Hi,
I am trying to calculate daily mean and daily range from a timetable:
'25-Feb-2008 00:00:00' 29.1580000000000
'25-Feb-2008 00:30:00' 29.1350000000000
'25-Feb-2008 01:00:00' 29.1400000000000
'25-Feb-2008 01:30:00' 29.1350000000000
'25-Feb-2008 02:00:00' 28.9070000000000
...
By using:
Dmean=retime(Tabla,'Daily',@nanmean);
Drange=retime(Tabla,'Daily',@range);
It works fine, for @nanmean, for days with data and some NaN's, or the entire day with only NaN's.
But this doesn't work for @range, do you know of any range function to use in timetable that works similar to nanmean?
I also tried:
[s,l]=retime(Tabla,'Daily',@bounds)
But received this error: Error using timetable/retime Too many output arguments.
And this:
retime(Tabla,'Daily',@bounds)
But received this error:
Error using timetable/retime (line 103)
Aggregation method 'bounds' returned value that did not have exactly one row.
Suggestions are welcome. Thanks!
  댓글 수: 4
KSSV
KSSV 2017년 9월 12일
That case you needs to fill the NaN's
Robert
Robert 2017년 9월 12일
Replacing NaNs with a number will help when full days (at minutes time steps) happen, but will affect the days that have some data and NaNs (mean calculation). I appreciate your suggestions.

댓글을 달려면 로그인하십시오.

채택된 답변

Peter Perkins
Peter Perkins 2017년 9월 14일
Robert, it's not clear what you are looking for, or what you mean by "doesn't work". As KSSV says, range ignores NaNs, so it's not clear what problem you are running into.
If you are doing aggregation with synchronize, you can write your own function to do whatever you want. You could easily write a v ersion of range that did NOT ignore NaNs, for example.
  댓글 수: 1
Robert
Robert 2017년 9월 14일
Thanks, I am using this function now:
function y = nanrange(x)
y = range(x);
if isempty(y)
y = nan;
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time Series에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by