Azzera filtri
Azzera filtri

How can I index these matrix blocks into numbers?

1 visualizzazione (ultimi 30 giorni)
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?
Any help will be excellent!

Risposta accettata

Stephen23
Stephen23 il 6 Nov 2018
Modificato: Stephen23 il 6 Nov 2018
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

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by