Repeating Matrix Element Until N Times

조회 수: 10 (최근 30일)
Dirga Eka Putra L
Dirga Eka Putra L 2018년 9월 23일
댓글: Dirga Eka Putra L 2018년 9월 23일
Excuse me everyone, I want ask that how to repeating the matrix element like this example :
Example: y = [1; 2; 3; 4] and then I want the output like this (for example until N=7) :
Thanks
  댓글 수: 2
Matt J
Matt J 2018년 9월 23일
편집: Matt J 2018년 9월 23일
Why is there a '5' in x but not in y?
Dirga Eka Putra L
Dirga Eka Putra L 2018년 9월 23일
편집: Dirga Eka Putra L 2018년 9월 23일
Sorry Sir, I have a typo, I Fixed (for Example N=7) :
Thanks

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

채택된 답변

Matt J
Matt J 2018년 9월 23일
m=numel(y);
y(mod(0:N-1,m)+1)

추가 답변 (1개)

dpb
dpb 2018년 9월 23일
Just one of many possible ways...
L=length(y);
N=7;
x=repmat(y,ceil(N/L),1);
x=x(1:N);

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by