How to replace the elements of a matrix with another matrices

3 次查看(过去 30 天)
Hi all,
How to replace the elements of a matrix with another matrices in one go with just a command?
for example: A = zeros(4,16) I want to replace the rows of A with the following matrices:
b=[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
c=[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]
d=[3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3]
e=[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]
Thanks for your help.
Best wishes, S:-)

采纳的回答

Image Analyst
Image Analyst 2014-1-13
编辑:Image Analyst 2014-1-13
Try this:
A = [b;c;d;e]

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2014-1-13
repmat((1:4)',1,16)
  1 个评论
S
S 2014-1-13
Thanks for your quick reply Azzi. But matrices b to e are just examples here, and in my case they do not have such a simple elements. Thanks anyway:)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by