Skip to content

Instantly share code, notes, and snippets.

@chappjc
Created March 16, 2015 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chappjc/bd440ae2922f91082f04 to your computer and use it in GitHub Desktop.
Save chappjc/bd440ae2922f91082f04 to your computer and use it in GitHub Desktop.
function out = rld_cumsum(vals,runlens)
% gnovice's solution to run-length-decoding
% (http://stackoverflow.com/a/1975835/2778484)
index = zeros(1,sum(runlens));
index([1 cumsum(runlens(1:end-1))+1]) = 1;
out = vals(cumsum(index));
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment