I have a vector (A) with some numbers, then I want to find which one is the closest to the value b.
A=[-0.1000 -0.0800 -0.0600 -0.0400 -0.0200 0 0.0200 0.0400 0.0600 0.0800 0.1000];
In this case, both -0.04 and -0.02 are at the same distance, then I want to select -0.04
I tried several methods, but for some reason, Matlab completely ignores the possibility of -0.04
if minimum == difference(i)
I am so frustrated, technically, this line of code should return all the appereances, so two, but it only returns one!
[row,col] = find(difference==val)
I will really appreciate some help with this. Clearly I am doing something wrong, but I have no clue what.