MATLAB: Unable to use the rowfun function

errorfunction_handlerowfun

I'm attempting to use the rowfun function as such:
A = rowfun(@(x,y) etime(datevec(y), datevec(x)), B(:,3:4));
However when I do this I get the following error:
Undefined function 'rowfun' for input arguments of type 'function_handle'.
This doesn't make any sense however, as the signature of the method explicitly states that the method takes a function handle. So what am I doing wrong here?

Best Answer

As the documentation states, rowfun is intended to "Apply function to table or timetable rows". The second input must be a table or timetable. Is B a table or a timetable?
If you want to iterate over the rows of a numeric array, use arrayfun with a vector running from 1 to size(theNumericArray, 1) and index into rows of the numeric array inside the function handle you pass into arrayfun.