Set Operations

Matlab Operations


MATLAB 没有所谓集合 set 数据类型, 这里的集合就是指的 Matlab Array, 其中元素可以为任意数据类型.

Functions

MATLAB 没有集合运算的运算符, 只有通过简单函数实现运算.

FunctionsDescription
intersectSet intersection of two arrays
ismemberArray elements that are members of set array
setdiffSet difference of two arrays
setxorSet exclusive OR of two arrays
unionSet union of two arrays
uniqueUnique values in array
ismembertolMembers of set within tolerance
uniquetolUnique values within tolerance
joinCombine two tables or timetables by rows using key variables
innerjoinInner join between two tables or timetables
outerjoinOuter join between two tables or timetables

/! Tolerance

  • MATLAB 中一个常见的问题就是因为浮点数精度的原因, 两个数字很难完全相等, 所以可以用 …tol 函数来接受允许误差
  • MATLAB 默认 tolerance 为
    • single 类: 1e-6
    • double 类: 1e-12