A=rand(20,20,10);
[height,width,n]=size(A);
n_train=n;
m=4;
b_width=height*width/m;
b_height=m;
b_train=zeros(b_height,b_width,n_train);
for k=1:n_train
%B=mat2cell(A,ones(50/10,1)*10,ones(40/10,1)*10);
B=mat2cell(A(:,:,k),ones(20/10,1)*10,ones(20/10,1)*10);
temp=[];
for i=1:2
for j=1:2
b_train_vetor=reshape(B{i,j}',1,b_width);
temp=[temp;b_train_vetor];
end
end
b_train(:,:,k)=temp;
end