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

1 次查看(过去 30 天)
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.

采纳的回答

Chinmay Anand
Chinmay Anand 2019-6-21
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 个评论

请先登录,再进行评论。

更多回答(1 个)

madhan ravi
madhan ravi 2019-6-21
Probably you want:
idx = setdiff(1:numel(A),B);
A(idx) = 0;

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by