Looping for replace matrix elements

조회 수: 17 (최근 30일)
Ana Rizkasari
Ana Rizkasari 2016년 11월 24일
답변: the cyclist 2016년 11월 24일
Helo,
I have matrix 3x3, let's say
XX = [3,0,0;
0,3,3;
4,5,4]
I want to generate matrix 9x3 which value same with matrix XX every forth row. as illustration:
XXnew = zeros (9,3)
as result :
XXnew = [3,0,0;
0,3,3;
4,5,4;
3,0,0;
0,3,3;
4,5,4;
3,0,0;
0,3,3;
4,5,4];
How to code with "for end" function.
Thank you!

채택된 답변

KSSV
KSSV 2016년 11월 24일
XX = [3,0,0;0,3,3;4,5,4] ;
iwant = repmat(XX,3,1);
doc repmat.

추가 답변 (1개)

the cyclist
the cyclist 2016년 11월 24일
XXnew = repmat(XX,3,1);

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by