Repeat matrix element of a given matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Nikhil Chourasia
el 11 de Mzo. de 2015
Comentada: Andrei Bobrov
el 13 de Mzo. de 2015
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 comentario
Respuesta aceptada
Jan
el 11 de Mzo. de 2015
Editada: Jan
el 11 de Mzo. de 2015
x = [2 5 3 6 1];
y = reshape(repmat(x, 4, 1), 1, []);
Or:
y = kron(x, ones(1, 4));
3 comentarios
Guillaume
el 13 de Mzo. de 2015
That would be
x = y(1:4:end);
This is basic matrix indexing.
In the future, start a new question rather than asking in comments.
Más respuestas (3)
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!