How can I index these matrix blocks into numbers?
1 回表示 (過去 30 日間)
古いコメントを表示
I have a 80×80 matrix A and divide it into 16 blocks of size 20x20, by
A=rand(80,80);
C= mat2cell(A,[20 20 20 20 ],[20 20 20 20]);
And I want to index these blocks in order from 1 to 16 like the figure shows, how can I do this?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193919/image.png)
Any help will be excellent!
0 件のコメント
採用された回答
Stephen23
2018 年 11 月 6 日
編集済み: Stephen23
2018 年 11 月 6 日
Actually you can already access it like you want, using linear indexing. Try it:
C{1}
C{2}
...
C{16}
Here is a demonstration using the second-to-last cell, C{15}:
>> A = rand(80,80);
>> C = mat2cell(A,[20,20,20,20],[20,20,20,20]);
>> isequal(C{15},A(41:60,61:80))
ans = 1
2 件のコメント
Stephen23
2018 年 11 月 6 日
If this is related to your earlier question:
Then all you need is this:
C = mat2cell(...)
C(:) = C(V);
new = cell2mat(C)
その他の回答 (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!