Is there a way to do a by row comparison of two data sets with the same number of columns, different number of rows, and different parameters for each column?

I have two data sets and I want to compare them each row in one set to every row in the other with different comparison parameters for each column. Example: If the comparison is that 1a=1b if 1b is in the range of 1a+/-0.0001 and 2a=2b if 2b is the range of 2a +/- 1. Where 1 or 2 is the column number and a or b notates the data set.
&nbsp
So the entries in row 1 are equal in both data sets and row 2 in data set A is equal to row 3 in data set B.

Respuestas (2)

A = [1.0001 2.0002;
8.1234 5.0];
B = [1.0002 3.0;
8.1235 3.0
8.1233 6.0];
tol = [0.001 1];
nB = size(B, 1);
R = nan(size(A,1), nB);
Tol = repmat(tol, [nB 1]);
for i = 1:size(A,1)
R(i,:) = all(abs(B - repmat(A(i,:), [nB 1])) <= Tol, 2);
end

La pregunta está cerrada.

Etiquetas

Preguntada:

el 2 de Jul. de 2015

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by