How to repeat elements of a matrix
Mostra commenti meno recenti
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 Commenti
Jon
il 4 Apr 2023
I don't understand what you are trying to do. Please give an example. I can imagine that you are trying to do something like this
A = rand(8,16);
B = repmat(A,1,31);
but since 16 doesn't divide 500 you can't exactly get an 8 by 500 matrix, the above gives a 8 by 496 matrix, basically putting 31 copies of A side by side
charu shree
il 4 Apr 2023
Steven Lord
il 4 Apr 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?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!