How to use find command for non-integer array?
9 views (last 30 days)
Show older comments
This is my algorithm, but the problem is "corrl" and "threshold" are non-integer arrays, and resulted in empty matrix. Is there any other alternative to find the same problem??
[dmin,tmin]=find(corrl<-threshold)
[dmax,tmax]=find(corrl>threshold)
2 Comments
Dyuman Joshi
on 20 Mar 2023
Edited: Dyuman Joshi
on 20 Mar 2023
There is no relation between the arrays being non-integer and the result being empty matrix. The functionality of find() is the same for all numeric data types. The result corresponds to the condition(s) satisfied.
Are all values in threshold and corrl positive? If yes, then the first condition will never be satisfied, and thus the output will be an empty matrix.
It's difficult to say about the second condition without any data. Please attach your data using the paperclip icon.
DGM
on 20 Mar 2023
The fact that the arrays are non-integer shouldn't be an issue unless you're trying to test for equality (or near-equality) conditions, which you aren't.
x = randn(1,10)
thresh = 0.01*ones(size(x));
[r1 c1] = find(x<-thresh)
[r2 c2] = find(x>thresh)
Without knowing what ether array look like, I'd have to guess that the conditions simply aren't being met. What is the output of
nnz(corrl>threshold)
If it's zero, then there are no matches.
Answers (1)
Sugandhi
on 20 Mar 2023
Hi Rahul,
I understand that you are trying to get row and column subscripts of each nonzero element after comparing corrl and threshold arrays whose elements are non - integers.
It results in empty matrix because no pair is satisfying the relational condition i.e., every pair return 0.
Go through this example:
v1 = [0.55 2.32;0.42 1.89];
v2 = [0.34 ;0.22];
res= v1<-v2
[x1,y1]=find(v1<-v2)
[x2,y2]=find(v1>v2)
For more understanding kindly go through the following link –
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!