分块矩阵转化成向量后合并

2018-06-12  本文已影响29人  Gunther17
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



A_matrix.png



b_train__matrix.png
上一篇 下一篇

猜你喜欢

热点阅读