Neglecting difference between two values if it is very small so that value1= value2

1 次查看(过去 30 天)
I am working on a dataset. After some eigendecompostion process. I realise the difference between my values are as small as 1.8097e-14 which is my further implementation process.
Example
data1(1:10) = 0 0.1502 0.2970 0.4371 0.5673 0.6845 0.7863 0.8702 0.9343 0.9773
data2(1:10) = -0.0000 0.1502 0.2970 0.4371 0.5673 0.6845 0.7863 0.8702 0.9343 0.9773
C= data1(1:10)-data2(1:10)
C =
1.0e-12 *
0.0862 0.1227 0.1545 0.0772 0.1019 0.1178 -0.0174 0.0048 0.0170 0.0181
How do I code that the these difference be neglected so that values in data1 & data2 will be equal since the difference is very small

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2021-7-28
编辑:Fangjun Jiang 2021-7-28
To compare element by element, abs(C) < Tolerance
To compare the two vectors as a whole, all(abs(C) < Tolerance)
or use
ismembertol(C,0,Tolerance)
  7 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by