find function does not output values
3 views (last 30 days)
I am using the find function. I have an 1196x1600 array called 'test' with some values zero and others nonzero. I use the following command to get the indices and values:
the rows and cols vectors work well, but the vals vector just outputs logical array with a 1 in every cell. The doc for find says that this will output the values associated with the indices but it is not doing that. Please help.
Guillaume on 17 Dec 2014
Edited: Guillaume on 17 Dec 2014
"this will output the values associated with the indices but it is not doing that".
Yes, it is. The matrix that you pass to find is not the test matrix but:
test ~= 0
which is a logical array. Hence its values are either 0 (false) or 1 (true).
It's very simple to fix in your case:
[rows, cols, vals] = find(test);