Repeat matrix element of a given matrix
Show older comments
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 Comment
Jan
on 11 Mar 2015
This topic is discussed such frequently, that I miss it in the FAQ.
Accepted Answer
More Answers (3)
Another quick one-liner:
reshape(ones(4,1)*x,1,[])
Andrei Bobrov
on 11 Mar 2015
x = [2 5 3 6 1];
y = x(ceil((1:4*numel(x))/4));
3 Comments
Nikhil Chourasia
on 11 Mar 2015
Nikhil Chourasia
on 13 Mar 2015
Andrei Bobrov
on 13 Mar 2015
x = unique(y);
Categories
Find more on Data Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!