0
Ich habe eine M
× N
Matrix A
, und eine M
× 1
Indexvektor ind
. Ich möchte einen N
× 1
Vektor c
erhalten, wobei c(i) = A(ind(i),i)
für i
= 1
, 2
, ..., N
.Wie wählt man ein Element aus jeder Spalte einer Matrix aus einem neuen Vektor?
Zum Beispiel lassen
A = hilb(5);
ind = [2,3,1,4,2]';
Wie kann ich Vektor c
bekommen?
Überprüfen Sie ['sub2ind'] (https://es.mathworks.com/help/matlab/ref/sub2ind.html) –