How to find values in a matrix corresponding to the values in another matrix
Mostrar comentarios más antiguos
Hi, I have a MxN matrix and want to pick the values from a column corresponding to the values in another column. Is there some way of doing this?
Respuestas (1)
Image Analyst
el 15 de Oct. de 2012
Hopefully this is rather self-explanatory:
% Get the two columns
anotherColumn = yourMatrix(:, 42); % or whatever column you want.
columnToSearch = yourMatrix(:, 13); % or whatever column you want to look in.
% Now get the value to look for
iWantThisValue = anotherColumn(23); % whatever....
% Find where that value occurs in the column you're searching.
% For example 0 0 0 1 1 0 0 1 0 0 1 1 1
logicalMapOfLocations = columnToSearch == iWantThisValue;
% Get the indexes, for example, [4 5 8 11 12 13]
indexes = find(logicalMapOfLocations);
1 comentario
Sreeja
el 15 de Oct. de 2012
Categorías
Más información sobre Linear Algebra en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!