How to repeat elements of a matrix
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello all, I am having a matrix of size 8 by 16.
My query is how to obtain 8 by 500 matrix from 8 by 16 matrix.
Any help is highly appreciated.
3 commentaires
Steven Lord
le 4 Avr 2023
Why not just pad your 8-by-16 array with 500-16 columns of NaN values?
x = reshape(1:8*16, [8 16]);
x(:, 17:500) = NaN;
Or fill in with random values:
x = reshape(1:8*16, [8 16]);
x(:, 17:500) = rand(8, 500-16);
What are the specific requirements for how you want the additional columns to be created?
Réponse acceptée
Jon
le 4 Avr 2023
Modifié(e) : Jon
le 4 Avr 2023
So is this what you want?
A = rand(8,16);
B = [repmat(A,1,31) A(:,1:4)];
In this case the last 4 columns of the 8 by 500 are the first 4 columns of the original 8 by 16 but you could use other columns if you wanted, just put in the indices you want
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!