how do i change a matrix dimension from MxN to 100xN?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Image Analyst
2016 年 6 月 28 日
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?
採用された回答
Jennifer Rebbin
2023 年 9 月 20 日
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 件のコメント
その他の回答 (1 件)
the cyclist
2016 年 6 月 28 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!