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: AeroShield_PID.m
    path of file: ./repos/AutomationShield/matlab/examples/AeroShield/AeroShield_PID
    
    the code of the file until where you have to start completion: %{
  AeroShield closed-loop PID response example
  
  PID feedback control of pendulum angle of the AeroShield.
  
  This example initialises the sampling and PID cont
    
function
while(1)                % infinite loop, until "break" command is used 
    if (stepEnable)     % if next step is enable
        
     % Reading output value
        RAW = AeroShield.getRawAngle();   % get raw angle value
        y = map(RAW, startangle, lastangle, 0.0, 100.0); % map raw value to percent 
        
     % Pick reference
        if MANUAL                               % if Manual mode is active
            PWMvalue = AeroShield.referenceRead();          % read reference from potentiometer
            r=map(PWMvalue, 0, 5, 0, 100);               % map value to percent
        else 
            if (mod(k,secLength*j)==0);             % if is time for new reference 
            j=j+1;                                  % go to next reference
                if (j > length(R))                  % if at the end