plz help how can repetition rows matrix

조회 수: 1 (최근 30일)
eman baky
eman baky 2021년 7월 24일
편집: eman baky 2021년 7월 24일
how can repetition rows matrix deponds number if i have a=[ 1 0 0 ;0 0 1; 0 1 0] and n=4
i wanna have rep_a=[ 1 0 0; 0 0 1; 0 1 0 ;1 0 0]
if n=5 rep_a=[ 1 0 0; 0 0 1; 0 1 0 ;1 0 0;0 0 1]
  댓글 수: 2
dpb
dpb 2021년 7월 24일
HINT:
nR=size(a,1);
N=4;
M=fix(N/nR);
C=rem(N,M*nR);
eman baky
eman baky 2021년 7월 24일
Thanks

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

채택된 답변

Jan
Jan 2021년 7월 24일
a = [1 0 0; 0 0 1; 0 1 0];
rows = size(a, 1);
n = 5;
index = rem(0:n-1, rows) + 1
index = 1×5
1 2 3 1 2
b = a(index, :)
b = 5×3
1 0 0 0 0 1 0 1 0 1 0 0 0 0 1

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by