dividing a matrix into 5 different matrices
1 回表示 (過去 30 日間)
古いコメントを表示
Hello, I am looking to divide a large matrix Ds into 5 sections (the first 20% being the top 20% and so on), so far i have done this to get s1 the rounded figure for each 20%.
n = size(Ds);
s = n(1,1)/5;
s1 = round(s);
i was just cannot figure out the next step? im sure its very simplistic just cannot seem to get it out? any information regarding this topic would be greatly appreciated.
regards, cormac
0 件のコメント
回答 (1 件)
Stephen23
2015 年 4 月 25 日
編集済み: Stephen23
2015 年 4 月 25 日
There is no general solution to this as it could be defined in different ways depending on the number of rows in the matrix: what is 20% of a one row matrix? 20% of a two row matrix? 20% of a four row matrix?
Obviously if the number of rows of the matrix is a multiple of the blocks that you want, then the solution is easy using mat2cell and some simple division to calculate how many rows per block:
>> A = rand(10,4);
>> N = 5;
>> X = size(A);
>> B = mat2cell(A, X(1)/N * ones(1,N), X(2))
B =
[2x4 double]
[2x4 double]
[2x4 double]
[2x4 double]
[2x4 double]
If you can specify how to work with numbers of rows that are not multiples of the number of blocks, then we can show you how to code this too!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Computer Vision with Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!