MATLAB: For loop in an array to substract the values of the array and find a specific value

arrayfor loopif statementr2019b

I have an array of 200 values. This is the operation I need to program:
The value in the position X minus the value in the position Y EQUALS 0.55. Therefore, I am using a for loop and If statement.
The problem is that I know neither value nor the position of each value. I guess both of them are in the first 50 values of the array. So, how can I code the operation below n times (k-1, k-2, k-3 …) until I got this number, and disp the 'Here'?
I;
for k =length (I)
x=I(k)-I %Take last value and substract the first value of I, second, k times to the last value.
if x==0.55
disp 'Here'
else
disp 'Not here'
end
end

Best Answer

If you are trying to find the indices X and Y for which I(X) - I(Y) is equal to a given values, this is easily done without a loop with:
[X, Y] = find(I - I.' == seachvalue); %I must be a vector
This will returrn all the XY pairs that match.