Mack
Mack

Reputation: 675

Matlab Removing Every Other Element From A 3D Matrix

I have a three dimensional matrix from which I would like to remove every other entry from an LxLxL matrix, where L will vary each time I run the code. I have searched through the internet, and I can not seem to find anything helpful. Could someone possibly lend some help.

Thank you

Upvotes: 2

Views: 496

Answers (1)

kol
kol

Reputation: 28698

M = zeros(L, L, L);
% ...fill M...
M = M(1:2:L, 1:2:L, 1:2:L);

Upvotes: 2

Related Questions