How to split 128x128 array into 64 ( 2x128 ) ?

2 visualizzazioni (ultimi 30 giorni)
Hello
i have a 128x128 array which i need to split it into 64 array of size 2x128
How to do that ?
  2 Commenti
Stephen23
Stephen23 il 4 Dic 2021
The MATLAB approach, where A is your 128x128 array:
C = mat2cell(A, 2*ones(1,64), 128)
Muhammad Abdulrazek
Muhammad Abdulrazek il 4 Dic 2021
thank you Stephen, this work well

Accedi per commentare.

Risposta accettata

Voss
Voss il 4 Dic 2021
Let x be your original (128x128) array. Here's one way to create 64 arrays of size 2x128, which I will store in a single cell array called y:
[n,m] = size(x);
y = cell(1,n/2);
for i = 1:n/2
y{i} = x(2*i-[1 0],:);
end
This assumes you want pairs of adjacent rows of x to be a single element of y.
  3 Commenti
Voss
Voss il 4 Dic 2021
x_reconstructed = vertcat(y{:});
Muhammad Abdulrazek
Muhammad Abdulrazek il 4 Dic 2021
Thank You Benjamin, i appreciate it.

Accedi per commentare.

Più risposte (1)

Matt J
Matt J il 4 Dic 2021
Download mat2tiles from
A=rand(128);
Acell=mat2tiles(A,[2,inf])
Acell = 64×1 cell array
{2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double} {2×128 double}

Categorie

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

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by