MATLAB: How to split a vector into smaller vectors to run a recursive function more efficiently

recursivesplit vector

I would like to split a vector of numbers v = 1:1e6 into smaller subvectors, say 20 elements each, and then be able to do a recursive function of reversing the elements in each of those smaller subvectors. Please help!

Best Answer

Try this
v = 1:1e6;
n = 20;
v_parts = mat2cell(v, 1, n*ones(1,numel(v)/n));
v_parts_reversed = cellfun(@fliplr, v_parts, 'UniformOutput', 0);
Related Question