Azzera filtri
Azzera filtri

how to divide matrix in columns and pair them?

1 visualizzazione (ultimi 30 giorni)
hi i have the following matrix. i want to split this according to column and pair them [0,0; 5,10; 10,15; 85,90; 95,95]
result for first column:
[0,5;
5;10;
10,85;
85,95]
and result for second column
[0,10;
10;15;
15,90;
90,95]
kindly help me :)
regards

Risposta accettata

Walter Roberson
Walter Roberson il 8 Ago 2015
A = [0,0; 5,10; 10,15; 85,90; 95,95];
pairs = cell(size(A,2),1);
for K = 1 : size(A,2)
pairs{K} = [A(1:end-1,K), A(2:end,K)];
end
  3 Commenti
Walter Roberson
Walter Roberson il 8 Ago 2015
A = [0,0; 5,10; 10,15; 85,90; 95,95];
pairs = zeros(size(A,1)-1, 2, size(A,2));
for K = 1 : size(A,2)
pairs(:,:,K) = [A(1:end-1,K), A(2:end,K)];
end
Now pairs(:,:,K) corresponds to the K'th column of the original array.

Accedi per commentare.

Più risposte (0)

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by