Effacer les filtres
Effacer les filtres

Access matrix location on one matrix with the data location on another matrix

1 vue (au cours des 30 derniers jours)
I have two matrix say A & B if I have data stored in A and the data location of desired values in B how could I access Values of matrix A who are located at locations B.

Réponse acceptée

Chinmay Anand
Chinmay Anand le 21 Juin 2019
In case if A and B are vectors ,( 1 x n ) matrices
A(B) % It will give the values of A at indexes B
  3 commentaires
Chinmay Anand
Chinmay Anand le 21 Juin 2019
idx = setdiff(1:length(A),B); % indexes which are not in B
A(idx) = 0;
Rohan  Mehta
Rohan Mehta le 21 Juin 2019
Thank you so much this works !!!

Connectez-vous pour commenter.

Plus de réponses (1)

madhan ravi
madhan ravi le 21 Juin 2019
Probably you want:
idx = setdiff(1:numel(A),B);
A(idx) = 0;
  2 commentaires
Rohan  Mehta
Rohan Mehta le 21 Juin 2019
yes Exactly what I wanted
madhan ravi
madhan ravi le 21 Juin 2019
Modifié(e) : madhan ravi le 21 Juin 2019
Beware this method works even if A is a matrix more than 1 dimension unlike the other.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by