Populate Array with duplicate variables
显示 更早的评论
Hi,
I am trying to duplicate the elements within a Matlab array according to the position of elements of the array.
For instance,
x = [1,2,3,4,5,6,4,2,7,5,3] should become x1 = [1,1,2,2,3,3,4,4,5,5,6,6,4,4,2,2,7,7,5,5,3,3]
Thanks
采纳的回答
更多回答(1 个)
Jos (10584)
2013-9-19
Another ML-trick:
% data
x = [1 4 3 6] ;
n = 2 ;
% engine
y = kron(x,ones(1,n))
类别
在 帮助中心 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!