Created
March 16, 2015 23:41
-
-
Save chappjc/7db48721c09c29f607e9 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 V = knedlsepp5cumsumaccumarray(values, runLengths) | |
% knedlsepp's solution to run-length-decoding originally from http://stackoverflow.com/a/28615814/2778484 | |
% (results in http://stackoverflow.com/a/29079288/2778484) | |
%// Actual computation using column vectors | |
V = cumsum(accumarray(cumsum([1; runLengths(:)]), 1)); | |
V = V(1:end-1); | |
V = reshape(values(V),[],1); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment