フィルターのクリア

Identifying row in matrix, and find the corresponding row in other matrix

1 回表示 (過去 30 日間)
Haya A
Haya A 2018 年 7 月 23 日
コメント済み: Haya A 2018 年 7 月 25 日
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.

採用された回答

KSSV
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 ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by