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

조회 수: 1 (최근 30일)
Oscar Tsang
Oscar Tsang 2019년 1월 26일
댓글: madhan ravi 2019년 1월 27일
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??
madhan ravi
madhan ravi 2019년 1월 27일
Because there exists no such function named as threes,
doc ones
doc zeros

댓글을 달려면 로그인하십시오.

추가 답변 (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