how do i change a matrix dimension from MxN to 100xN?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Ganeshkumar M
el 28 de Jun. de 2016
Editada: James Tursa
el 20 de Sept. de 2023
Hi i have a matrix of size 46 x 1123 and i would want to expand it to a dimension of 100 x 1123. It will be best if the additional element rows are a copy of the original matrix as i will be using classify for subsequent manipulations.
Will be running this as a script hence the number of rows of 46 will differ from file to file but would want to standardise the output number of rows to 100. Thank you!
1 comentario
Image Analyst
el 28 de Jun. de 2016
The 54 rows to tack on are not a multiple of 46 so exactly how were you planning on filling those rows? What rows from the original 46 are to be copied into the 54 new rows? And do you want to insert the rows at the top, or bottom or both? Have you read this link yet?
Respuesta aceptada
Jennifer Rebbin
el 20 de Sept. de 2023
Starting in R2023b, you can use the paddata function to pad data by adding elements. For example, specify the size of the padded data and the pattern for adding elements.
A = rand(46,1123);
B = paddata(A,[100 size(A,2)],Pattern="circular")
0 comentarios
Más respuestas (1)
the cyclist
el 28 de Jun. de 2016
I have the same questions as Image Analyst asked, but here is my best guess as to what you want:
% Original matrix
A = rand(46,1123);
% New matrix
newRowCount = 100;
[m,n] = size(A);
B = zeros(newRowCount,n);
B = A(mod((1:newRowCount)-1,m)+1,:);
It fills in B from A row-by-row, repeating from the top of A if it reaches the bottom.
0 comentarios
Ver también
Categorías
Más información sobre Matrices and Arrays 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!