Compair two vectors with different length and different values??
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aubai
el 12 de Jul. de 2013
Comentada: Mohammad Bhat
el 7 de Abr. de 2018
Hallo
Lets say i have two vectors A, B with different length (Length(A) not equal to Length(B)) and the Values in Vector A, are not the same as in Vector B. i want to compair each value of B with Values of A (Compair means if Value B(i) is alomst the same value of A(1:end) for example B(i)-Tolerance<A(i)<B(i)+Tolerance.
How Can i do this without using For loop as the data are huge?
I know ismember, intersect,repmat,find but non of those function can really help me
2 comentarios
Jos (10584)
el 12 de Jul. de 2013
Huge is relative ... How would you do this using a for-loop? It might be easy to improve upon that.
What is it exactly you want to know. Your wordings suggest that you only want to see if an element of B is close one (or more) elements of A, while your formula suggests that you want it the other way around ...
Respuesta aceptada
Más respuestas (1)
Andrei Bobrov
el 12 de Jul. de 2013
A = randi(25,10,1);
B = randi(30,20,1);
tolerance = 1;
out = abs(bsxfun(@minus,B(:),A(:).')) < tolerance;
2 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!