필터 지우기
필터 지우기

How to repeat indivisual element of a matrix?

조회 수: 3 (최근 30일)
Saiem Solimullah
Saiem Solimullah 2018년 3월 17일
댓글: Saiem Solimullah 2018년 3월 21일
Suppose, i have a matrix a=[1 0 1 1 0 0 1 1] and i want to repeat every element of this matrix by 3 times using for loop . as the new matrix will be b=[1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1] . How easily can solve??

채택된 답변

Rene Riha
Rene Riha 2018년 3월 17일
for i=1:length(a)
b(3*i-2:3*i)=a(i);
end
  댓글 수: 2
Saiem Solimullah
Saiem Solimullah 2018년 3월 19일
Thank you... this is helpful..
Saiem Solimullah
Saiem Solimullah 2018년 3월 21일
mam, can u help me with the rebuilt of vector a using for loop please?

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

추가 답변 (1개)

Steven Lord
Steven Lord 2018년 3월 17일
Use the repelem function introduced in release R2015a.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by