Repeat matrix element of a given matrix
显示 更早的评论
my matrix is x=[2 5 3 6 1]
I want it to make it as y=[2 2 2 2 5 5 5 5 3 3 3 3 6 6 6 6 1 1 1 1]
which function does it?
1 个评论
Jan
2015-3-11
This topic is discussed such frequently, that I miss it in the FAQ.
采纳的回答
更多回答(3 个)
Another quick one-liner:
reshape(ones(4,1)*x,1,[])
Andrei Bobrov
2015-3-11
x = [2 5 3 6 1];
y = x(ceil((1:4*numel(x))/4));
类别
在 帮助中心 和 File Exchange 中查找有关 Data Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!