# how do i change a matrix dimension from MxN to OxN?

1 view (last 30 days)
Ganeshkumar M on 28 Jun 2016
Answered: the cyclist on 28 Jun 2016
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!
Image Analyst on 28 Jun 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?

the cyclist on 28 Jun 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.