Repeat copies of array elements: Run-length decoding in MATLAB

后端 未结 5 1489
猫巷女王i
猫巷女王i 2020-11-22 08:36

I\'m trying to insert multiple values into an array using a \'values\' array and a \'counter\' array. For example, if:

a=[1,3,2,5]
b=[2,2,1,3]
5条回答
  •  逝去的感伤
    2020-11-22 09:15

    The performance problems in MATLAB's built-in repelem have been fixed as of R2015b. I have run the test_rld.m program from chappjc's post in R2015b, and repelem is now faster than other algorithms by about a factor 2:

    Updated plot comparing repelem execution time of different methods Speedup of repelem over cumsum+diff (about a factor 2)

提交回复
热议问题