Is there a vectorised way to do the following? (shown by an example):
input_lengths = [ 1 1 1 4 3 2 1 ] result = [ 1 2 3 4 4 4 4 5 5 5 6 6 7 ]
A fully vectorized version:
selector=bsxfun(@le,[1:max(input_lengths)]',input_lengths); V=repmat([1:size(selector,2)],size(selector,1),1); result=V(selector);
Downside is, the memory usage is O(numel(input_lengths)*max(input_lengths))