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: battery.m
    path of file: ./repos/Robotics-Toolbox/rvctools/release10.3.1/robot/interfaces/@Create
    
    the code of the file until where you have to start completion: function Percent = battery(robot)
% Displays the current percent charge remaining in Create's Battery 

% By; Joel Esposito, US Naval Academy, 2011

    robot.flush();

    robot.write([142 25]);
    charge =  robot.fread(1, 'uint16');
    robot.write([142 26]);

    
function Percent = battery(robot)
% Displays the current percent charge remaining in Create's Battery 

% By; Joel Esposito, US Naval Academy, 2011

    robot.flush();

    robot.write([142 25]);
    charge =  robot.fread(1, 'uint16');
    robot.write([142 26]);
    capacity =  robot.fread(1, 'uint16');

    percent=charge/capacity*100;

    if nargout == 0
        fprintf('battery  %.0f%%\n', percent);
    else
        Percent = percent;
    end