How to replace elements of matrix by elemts from array
Mostrar comentarios más antiguos
k = 8;
x = 1:2500; % array
h = 1:257;
newV = (0:length(x)-1).'*k+h;% matrix of indices
I have created matrix of indices, wich contains indexes of array x. Now I want to replace all elements of matrix by elemts from array x.
It should like this:
NewV = [x (1) x (2) x(3) ... ; x(9)... ; x(17)... ; x(25)... ]
Respuestas (2)
Akira Agata
el 27 de Dic. de 2019
Basically, this task can be done by:
NewV = reshape(x,8,[])';
But in your case, length(x) can NOT be devided by k (=8). So you should adjust length(x) by padding/removing some elements.
2 comentarios
Dmitry Timofeev
el 27 de Dic. de 2019
Dmitry Timofeev
el 27 de Dic. de 2019
Editada: Dmitry Timofeev
el 27 de Dic. de 2019
Andrei Bobrov
el 27 de Dic. de 2019
out = x(NewV);
Categorías
Más información sobre Operators and Elementary Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!