How do I find if array A is element of array B within interval?

1 次查看(过去 30 天)
Hello,
I'm looking for possibility to get True Positive/ False Negative/ False Positive values.
For example, I have two arrays
A = [1000, 1200,1200,1700];
and
B = [0, 0, 1500, 1250, 1250, 2300, 200];
A are frequencies, B are detected frequencies-vector.
First I'm using:
A = nonzeros(unique(A));
B = nonzeros(unique(B));
to avoid zeros and repeats and get:
A = [1000, 1200, 1700];
B = [200, 1250, 1500, 2300] ;
Now I want to look for:
if values B are elements of A +-var-Value
than TP = TP + 1;
if values B are not elements of A +-var-Value
than FP = FP + 1;
if values A are not elements of B +-var-Value
than FN = FN + 1;
end
when var-Value = 100;
There are 3 frequencies 1000, 1200, 1700
4 frequencies are detected 200, 1250, 1500, 2300
1200 is detected (1250 - of course of var-Value interval) -> True Positive = 1
1000 and 1700 was not detected -> False Negative = 2
200, 1500 and 2300 was wrong detected -> False Positive = 3
I find an ismember(A,B) function, but there are no interval option for +-var-Value possible
So I can use a for-loops to check it, but there are maybe better solution possible?
Thank you!
  3 个评论
Nik Rocky
Nik Rocky 2020-6-7
Yes, thank you, i found it allready =)
Here is my code:
Analyse1 = ismembertol(frequency_detected, frequency_actual, tube_var, 'DataScale' , 1)
Analyse2 = ismembertol(frequency_actual, frequency_detected, tube_var, 'DataScale' , 1)
TP_help = nnz(Analyse1); %right frequency detected
FP_help = nnz(~Analyse1); %wrong frequency detected
FN_help = nnz(~Analyse2); %no frequency detected

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by