ТОР 5 статей: Методические подходы к анализу финансового состояния предприятия Проблема периодизации русской литературы ХХ века. Краткая характеристика второй половины ХХ века Характеристика шлифовальных кругов и ее маркировка Служебные части речи. Предлог. Союз. Частицы КАТЕГОРИИ:
|
Пересечение множествIntersect Find set intersection of two vectors c = intersect(A, B) returns the values common to both A and B. In set theoretic terms, this is A[[INTERSECT]] B. Inputs A and B can be numeric or character vectors or cell arrays of strings. The resulting vector is sorted in ascending order.
c = intersect(A, B, 'rows') when A and B are matrices with the same number of columns returns the rows common to both A and B.
[c, ia, ib] = intersect(a, b) also returns column index vectors ia and ib such that c = a(ia) and c = b(ib) (or c = a(ia,:) and c = b(ib,:)).
A = [1 2 3 6]; B = [1 2 3 4 6 10 20]; [c, ia, ib] = intersect(A, B); disp([c; ia; ib]) 1 2 3 6 1 2 3 4 1 2 3 5 Setdiff Find set difference of two vectors c = setdiff(A, B) returns the values in A that are not in B. In set theory terms, c = A - B. Inputs A and B can be numeric or character vectors or cell arrays of strings. The resulting vector is sorted in ascending order. c = setdiff(A, B, 'rows'), when A and B are matrices with the same number of columns, returns the rows from A that are not in B. [c,i] = setdiff(...) also returns an index vector index such that c = a(i) or c = a(i,:).
A = magic(5); B = magic(4); [c, i] = setdiff(A(:), B(:)); c' = 17 18 19 20 21 22 23 24 25 i' = 1 10 14 18 19 23 2 6 15
Setxor Find set exclusive OR of two vectors (исключительное «или», без пересечения) c = setxor(A, B) returns the values that are not in the intersection of A and B. Inputs A and B can be numeric or character vectors or cell arrays of strings. The resulting vector is sorted. c = setxor(A, B, 'rows'), when A and B are matrices with the same number of columns, returns the rows that are not in the intersection of A and B. [c, ia, ib] = setxor(...) also returns index vectors ia and ib such that c is a sorted combination of the elements c = a(ia) and c = b(ib) or, for row combinations, c = a(ia,:) and c = b(ib,:).
a = [-1 0 1 Inf -Inf NaN]; b = [-2 pi 0 Inf]; c = setxor(a, b) c = -Inf -2.0000 -1.0000 1.0000 3.1416 NaN Не нашли, что искали? Воспользуйтесь поиском:
|