Identifying row in matrix, and find the corresponding row in other matrix
2 次查看(过去 30 天)
显示 更早的评论
Hi guys
I am trying to find a way to identify the row where a certain condition applied to cell, then go to another matrix and find the corresponding row or columns, and do some mathematical operation such multiplying and sum between the columns in the first matrix, which contains the found cell, with the same row in the second matrix.
for example, I am search for value X in matrix 1, after finding the cell with value X, I want to know the row number then go to matrix 2 to fetch the values of this row to multiply it with the first columns which contains the value X.
To be clear, the second matrix is Symmetric matrix, so columns or rows gives the same result.
0 个评论
采纳的回答
KSSV
2018-7-23
Read about logical indexing in MATLAB. Check the below example:
% Make some random data
vals = rand(15,1) ;
A = reshape(randsample(vals,9),3,3) ;
B = reshape(randsample(vals,9),3,3) ;
% Find A(2,1) in A and B
idx = A==A(2,1) ;
A(idx)
B(idx)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!