Your code will fail if i happens to reach fil, since s(i+1, 2) is then not valid.
You will need a loop to go over the different csv files, but you certainly don't need a loop for finding your row:
s = csvread('scope_1_1.csv', 2, 0);
thresholdindices = find(s(1:end-1, 2) < 0.5 & diff(s(:, 2)) > 2, 25);
if numel(thresholdindices) < 25
error('there was less than 25 values that matched the threshold');
end
thresholdvalue = s(thresholdindices(end), 1);