Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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.

Respuesta aceptada

KSSV
KSSV el 23 de Jul. de 2018
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)

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by