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.
0 个评论
采纳的回答
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
更多回答(1 个)
madhan ravi
2019-6-21
Probably you want:
idx = setdiff(1:numel(A),B);
A(idx) = 0;
2 个评论
madhan ravi
2019-6-21
编辑:madhan ravi
2019-6-21
Beware this method works even if A is a matrix more than 1 dimension unlike the other.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!