Created
March 16, 2015 18:17
-
-
Save chappjc/fc9047dae632da6fc65c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function out = rld_cumsum_diff(vals,runlens) | |
% Divakar's solution to run-length-decoding | |
% (http://stackoverflow.com/a/29079288/2778484) | |
clens = cumsum(runlens); | |
idx(clens(end))=0; | |
idx([1 clens(1:end-1)+1]) = diff([0 vals]); | |
out = cumsum(idx); | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment