矩阵有些行需要重复

%% 矩阵a每一行重复n次 a为已知矩阵
m=size(a,1); % a有多少行?
b=[]
n=5;
for i=1:m
b0=repmat(a(i,:),n,1);
b=[b;b0];
end
%% 矩阵a每m行重复n次,a为已知矩阵
b=[];
n=5;
m=5;
k=size(a,1)/m; %循环k次
for i=1:k
b0=repmat(a((i*m-(m-1)):m*i,:),n,1);
b=[b;b0];
end

Leave a Reply

Your email address will not be published. Required fields are marked *