function Ind = BinarySearch(SortList,t)
%Ind = BinarySearch(SortList,t)
%inputs:  SortList = a (row or column) vector whose components 
%increase in order, t = a number
%output:  Ind = an index at which vector SortList
%has t as corresponding component, will be zero if v
%does not have t as a component
%binary search algorithm is used
n=length(SortList); Ind =0; leftind=1; rightind=n;
while leftind<rightind
    m=floor((leftind+rightind)/2);
    if t==SortList(m), Ind = m; return
    elseif t>SortList(m), leftind = m+1;
    else rightind = m;
    end
end
