MATLAB: Forming loop to perform same action

for loopplot

I am having problem creating the loop for the task.
Thres = 0.17;
istrue1= ((x>=928 & x<=1139) & y>=Thres)|((x>=2527 & x<=2856) & y>=Thres)|((x>=4113 & x<=4376) & y>=Thres)|((x>=5464 & x<=5643) & y>=Thres)|((x>=7254 & x<=7604) & y>=Thres);
TP = sum(istrue1);
Using the command I can find out the value of TP for a particular value of thres. But I want to vary the value of thres from 0:0.1:1 and want to get 10 values of TP simultaneously rather than changing Thres each time. I know it is easy but not for me. Please help.

Best Answer

Thres = 0.17;
istrue1=((x>= 928 & x<=1139) & y>=Thres) | ...
((x>=2527 & x<=2856) & y>=Thres) | ...
((x>=4113 & x<=4376) & y>=Thres) | ...
((x>=5464 & x<=5643) & y>=Thres) | ...
((x>=7254 & x<=7604) & y>=Thres);
is same as
istrue1=(x>= 928 & x<=1139 | ...
x>=2527 & x<=2856 | ...
x>=4113 & x<=4376 | ...
x>=5464 & x<=5643 | ...
x>=7254 & x<=7604) & y>=Thres);
Is place for my "syntactic sugar" helper utility iswithin...
istrue1=(iswithin(x, 928,1139) | ...
iswithin(x,2527,2856) | ...
iswithin(x,4113,4376) | ...
iswithin(x,5464,5643) | ...
iswithin(x,7254,7604)) & y>=Thres);
to reduce the clutter of all the tests conditions by moving into the function.
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
flg= (x>=lo) & (x<=hi);
end