Access matrix location on one matrix with the data location on another matrix
Show older comments
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.
Accepted Answer
More Answers (1)
madhan ravi
on 21 Jun 2019
Probably you want:
idx = setdiff(1:numel(A),B);
A(idx) = 0;
2 Comments
Rohan Mehta
on 21 Jun 2019
madhan ravi
on 21 Jun 2019
Edited: madhan ravi
on 21 Jun 2019
Beware this method works even if A is a matrix more than 1 dimension unlike the other.
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!