How to index specific values out of a 2D array using overloaded 'find' function.

39 vues (au cours des 30 derniers jours)
Alex Burrows
Alex Burrows le 24 Oct 2015
Modifié(e) : Jan le 24 Oct 2015
I have loaded a 2D array (dataArray) of data from an excel spreadsheet. I have used the below code to find the needed values:
[row, column] = find(dataArray < 83);
This successfully gave me each corresponding row and column value stored in the variables 'row' & 'column'.
When I use the following code: dataValues = dataArray(row, column); it assigns back to me a new array of incorrect values. So my question is how do I index out the correct individual values?

Réponses (1)

Jan
Jan le 24 Oct 2015
Modifié(e) : Jan le 24 Oct 2015
The easiest would be:
[row, column, dataValues] = find(dataArray < 83);
Or using the indices:
dataValues = datArray(sub2ind(size(dataArray, row, column));

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by