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));
댓글 수: 3
Nikhil Chourasia
2015년 3월 11일
Nikhil Chourasia
2015년 3월 13일
Andrei Bobrov
2015년 3월 13일
x = unique(y);
카테고리
도움말 센터 및 File Exchange에서 Data Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!