Delete the center in an array?
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Mohanned Al Gharawi
il 27 Ott 2017
Commentato: Star Strider
il 27 Ott 2017
Hi everybody,
I have an array, let's say 6x6, how to delete the center of this array. I mean I want to delete 3x3 center of this array.
simple example, if we have an array 6x6 with elements:
6 5 2 2 1 9
4 3 0 1 2 8
5 5 6 2 1 7
9 8 0 1 0 6
4 4 1 1 0 5
2 1 1 2 3 4
and I want to delete the center which are:
6 2
0 1
I hope you could help me, I've tried several time to solve it but I couldn't.
Thanks in advance.
4 Commenti
Risposta accettata
Star Strider
il 27 Ott 2017
‘I want to delete specific elements(3x3 or 2x2 whatever) inside a big array, and convert the rest of this array into a vector.’
That is straightforward:
A = [6 5 2 2 1 9
4 3 0 1 2 8
5 5 6 2 1 7
9 8 0 1 0 6
4 4 1 1 0 5
2 1 1 2 3 4];
Lidx = sub2ind(size(A), [3 3; 4 4], [3 3; 4 4]);
Center = A(Lidx) % View Elements
A(Lidx) = []; % Delete Elements, Return Vector
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Cell Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!