You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: f_dig_filter.m
    path of file: ./repos/HRTF-Individualization/model/matlabcode/functions/filter
    
    the code of the file until where you have to start completion: 

function f= f_dig_filter(x)

global edges ws T weight1 weight2 weight3 w p J L M_First M_Second M_Third

    
function f= f_dig_filter(x)

global edges ws T weight1 weight2 weight3 w p J L M_First M_Second M_Third



Num=zeros(L,J);
Den=zeros(L,J);


for i=1:L
    

    if w(i)<=edges(1)
        M0(i)=M_First;
        weight=weight1;
    elseif w(i)<=edges(3) & w(i)>=edges(2)
        M0(i)=M_Second;
        weight=weight2;
    elseif w(i)<=(ws/2) & w(i)>=edges(4)
        M0(i)=M_Third;
        weight=weight3;
    end