How to use find command for non-integer array?
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
Dyuman Joshi
2023-3-20
编辑:Dyuman Joshi
2023-3-20
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
2023-3-20
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.
回答(1 个)
Sugandhi
2023-3-20
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!