Matching pair to some reference value
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
Dear All
I need help to find out the pairs which are equal to the some reference value e.g my data is given as
A(i)=d2_f(i);
B=([e1(i);e2(i);e3(i);e4(i);e5(i);e6(i);e7(i);e8(i);e9(i);e10(i);e11(i)]);
i want to find out which pairs in B can meet the value of A
Thanks in advance for answering
Antworten (2)
tol = 10^-6 ;
idx = abs(B-A)<=tol ;
[A B(idx')]
6 Kommentare
Amin Waqas
am 9 Apr. 2019
KSSV
am 9 Apr. 2019
Is A always a single number?
Amin Waqas
am 9 Apr. 2019
KSSV
am 9 Apr. 2019
tol = 10^-6 ;
iwant = cell(17520,1) ;
for i = 1:17520
A=d2_f(i);
B=([e1(i);e2(i);e3(i);e4(i);e5(i);e6(i);e7(i);e8(i);e9(i);e10(i);e11(i)]);
idx = abs(B-A)<=tol ;
iwant{i} = [A B(idx')] ;
end
You may read about ismembertol and avoid loop. Read about it.
Amin Waqas
am 9 Apr. 2019
KSSV
am 9 Apr. 2019
The error is simple.......see A is a single number and if B is row matrix..no error...if it is column matrix there will be error. Remove the transpose in idx.
iwant{i} = [A B(idx)]
madhan ravi
am 9 Apr. 2019
0 Stimmen
Simply use ismembertol()
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!