repeat a matrix in defined manner
1 次查看(过去 30 天)
显示 更早的评论
hi! How could i generate from this matrix:
A=[1 2 3
4 5 6
4 5 6]
this matrix:
B= [1 1 1 1 2 2 2 2 3 3 3 3
4 4 4 4 5 5 5 5 6 6 6 6
4 4 4 4 5 5 5 5 6 6 6 6]
thank you
0 个评论
采纳的回答
Azzi Abdelmalek
2012-12-12
编辑:Azzi Abdelmalek
2012-12-12
A=[1 2 3;4 5 6;4 5 6];
m=4
B=cell2mat(arrayfun(@(x) x*ones(1,m),A,'un',0))
0 个评论
更多回答(1 个)
Walter Roberson
2012-12-12
编辑:Walter Roberson
2012-12-12
kron(A,[1 1 1 1])
or
A(:, repmat(1:end,4,1) )
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!