how do i place a matrix on top of each other using repmat

4 次查看(过去 30 天)
I have 3 matrix's. Matrix Z1 with 5 rows and 5 columns of zeros, matrix Z2 with 5 rows and 10 columns of ones. And, matrix Z3 with 3 identical rows, each row containing the integers from 0 to 14. My aim is to have a matrix z that z1 and z2 will be tiles on top of matrix z3. I tried to combine both z1 and z2 into a matrix x then using repmat comand to put z3 matrix as the bottom tile. I don't know if im using the wrong command even.
The exspected output is this:
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 1 1 1 1 1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Any help is appriciated!! :)

采纳的回答

madhan ravi
madhan ravi 2019-1-26
z1=zeros(5);
z2=ones(5,10);
z3=repmat(0:14,5,1); % proper usage
Result=[z1 z2;z3] % concatenate z1 , z2 horizontally & z3 vertically.
  2 个评论
Oscar Tsang
Oscar Tsang 2019-1-26
when you did z1=zeros(5);. Why is it that when I chnage zeros to threes it won't work??

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by