How to concatenate multi rows in matrix ?

조회 수: 1 (최근 30일)
hewaa mero
hewaa mero 2013년 11월 28일
댓글: hewaa mero 2013년 11월 28일
How to concatenate multi rows in matrix, for example I've a matrix 6X8
x= 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5
6 6 6 6 6 6 6 6
the result like this
y = 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4
y = 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2
5 5 5 5 5 5 5 5
6 6 6 6 6 6 6 6
y = 3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5
6 6 6 6 6 6 6 6
tried concatenated row_row by this code below :
old=round(10*rand(6,8))
for n=1 :size(old)
for m=n+1:size(old)
newline = [old(n, :); old(m, :)]
end
end

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2013년 11월 28일
편집: Andrei Bobrov 2013년 11월 28일
y = 1:6;
o = reshape(bsxfun(@times,kron(fliplr(~eye(3)),[1 1]),y)',1,[]);
out = repmat(reshape(o(o~=0),4,1,[]),1,7);
ADD
old = randi(40,6,8)
t = kron(fliplr(~eye(3)),[1 1])'>0
for jj = size(t,2):-1:1
out(:,:,jj) = old(t(:,jj),:);
end
  댓글 수: 4
Andrei Bobrov
Andrei Bobrov 2013년 11월 28일
see ADD part
hewaa mero
hewaa mero 2013년 11월 28일
you mean I just use add part, and I used this part but answer not correct there 3 there matrix: out(:,:,1),out(:,:,2)again out(:,:,1), and out matrix is not ordered like that 1st part with 2nd part ,1st part with 3rd, 1st part with 4th,.....

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

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by