MATLAB: How to apply arrayfun for multiple column

arrayfun

Dear all, I am using following code for the one column in a data matrix. however, I have 60 columns and 6892 rows in the data matrix. How to apply the collowing code on the all columns, please suggest.
n = 6892; % total number of rows
m = 100; % window size
h = arrayfun(@(k)genhurst(y(k:m+k-1)),1:30:(n-m+1),'UniformOutput',false); % 30 is the forward shifting size
HH=h.';

Best Answer

If you really want to use arrayfun you could do it like this:
windowsize = 100; %why call it m when window size is a lot clearer?
[rows, cols] = ndgrid(1:30:size(y, 1)-windowsize+1, 1:size(y, 2));
HH = arrayfun(@(row, col) genhurst(y(row:row+windowsize-1, col)), rows, cols, 'UniformOutput', false);
or you could just use an explicit loop which might be clearer and faster.