This program compares numerical arrays up to a certain precision.
>> numcmp(x); % compares x==0.1
>> numcmp(x,'<=',y,3); % compares x<=y up to 0.001
See the screenshot for another example.
This is usefull to compare serial dates up to 0.1 seconds by using:
and avoiding floating point problems with the serial dates in days.
Carlos Adrian Vargas Aguilera (2020). numcmp.m (https://www.mathworks.com/matlabcentral/fileexchange/21190-numcmp-m), MATLAB Central File Exchange. Retrieved .
Thanks, helped me alot!
Bug report - precision is not persistent due to the fact that variables are rounded twice (each one once). Moreover, due to code in lines 103:105 overall precision depends on smallest value in arrays.
>> numcmp([0.076; 0],'==',[0.039; 0],1)'
>> numcmp([0.076; 1],'==',[0.039; 1],1)'
Bug report - second output to the function is not returned.
It is specified as variable DT, but later in code another variable BA is used.
Bug report - infinite values are not handled properly.
>> numcmp([1 1],'==',[1 inf],1)
Thanks for the entry. I found a small bug. If I put in a row vector, I get an error on line 103:
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in numcmp (line 103)
ABmin = min([A(isfinite(A)); B(isfinite(B))]); % Fixed bug SEP 09, 2008
Fixed bug with Infs inputs
Inspired: Floating point relational operator.