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: checkTermination.m
    path of file: ./repos/hongbomiao.com/aerospace/quadcopter-pd-controller/utils
    
    the code of the file until where you have to start completion: function [terminate_cond] = checkTermination(x, time, stop, pos_tol, vel_tol, time_tol)
    % Check termination criteria, including position, velocity and time

    % Initialize
    pos_check = true;
    vel_check = true;
    pos_col_check = zeros(1, 3);


    
function [terminate_cond] = checkTermination(x, time, stop, pos_tol, vel_tol, time_tol)
    % Check termination criteria, including position, velocity and time

    % Initialize
    pos_check = true;
    vel_check = true;
    pos_col_check = zeros(1, 3);

    % Check position and velocity and still time for each quad
    pos_check = pos_check && (norm(x(1:3) - stop) < pos_tol);
    vel_check = vel_check && (norm(x(4:6)) < vel_tol);
    pos_col_check(1, :) = x(1:3)';

    % Check total simulation time
    time_check = time > time_tol;

    if pos_check && vel_check
        terminate_cond = 1; % Robot reaches goal and stops, successful
    elseif time_check
        terminate_cond = 2; % Robot doesn't reach goal within given time, not complete
    else
        terminate_cond = 0;
    end