How to concatenate multi rows in matrix ?

1 Ansicht (letzte 30 Tage)
hewaa mero
hewaa mero am 28 Nov. 2013
Kommentiert: hewaa mero am 28 Nov. 2013
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

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 28 Nov. 2013
Bearbeitet: Andrei Bobrov am 28 Nov. 2013
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 Kommentare
Andrei Bobrov
Andrei Bobrov am 28 Nov. 2013
see ADD part
hewaa mero
hewaa mero am 28 Nov. 2013
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,.....

Melden Sie sich an, um zu kommentieren.

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by