How to concatenate multi rows in matrix ?

1 vue (au cours des 30 derniers jours)
hewaa mero
hewaa mero le 28 Nov 2013
Commenté : hewaa mero le 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

Réponses (1)

Andrei Bobrov
Andrei Bobrov le 28 Nov 2013
Modifié(e) : Andrei Bobrov le 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 commentaires
Andrei Bobrov
Andrei Bobrov le 28 Nov 2013
see ADD part
hewaa mero
hewaa mero le 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,.....

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by