1.作用:
重复数组
2.格式:
B = repmat(A,n)
B = repmat(A,r1,...,rN)
B = repmat(A,r)
eg:
1、假设:A为M*N,
当B = repmat(A,n)时, B大小为M*n * N*n
当B = repmat(A,m,n)时, B大小为M*m * N*n
2、A可以为矩阵,也可为字符串
>> a=[1,2,3;4,5,6];
>> b1=repmat(a,2)
b1 =
1 2 3 1 2 3
4 5 6 4 5 6
1 2 3 1 2 3
4 5 6 4 5 6
>> b2=repmat(a,2,3)
b2 =
1 2 3 1 2 3 1 2 3
4 5 6 4 5 6 4 5 6
1 2 3 1 2 3 1 2 3
4 5 6 4 5 6 4 5 6
>> c=[2,3];
>> b3=repmat(a,c)
b3 =
1 2 3 1 2 3 1 2 3
4 5 6 4 5 6 4 5 6
1 2 3 1 2 3 1 2 3
4 5 6 4 5 6 4 5 6
>> b=repmat('i am handsome !',2,2)
b =
2×30 char 数组
'i am handsome !i am handsome !'
'i am handsome !i am handsome !'