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: ex3d_command_pos_vel.m
    path of file: ./repos/hebi-matlab-examples/basic/x-series_actuator
    
    the code of the file until where you have to start completion: % Send simultaneous position and velocity commands, log in the background, 
% and plot offline.
%
% For more information type:
%    help CommandStruct
%    help HebiGroup
%
% Th
    
function
freqHz = 1.0;           % [Hz]
freq = freqHz * 2*pi;   % [rad / sec]
amp = deg2rad( 45 );    % [rad]

duration = 10; % [sec]
timer = tic();
while toc(timer) < duration

    % Even though we don't use the feedback, getting feedback conveniently 
    % limits the loop rate to the feedback frequency 
    fbk = group.getNextFeedback();
    t = toc(timer);

    % Position command
    cmdPosition = amp * sin( freq * t );

    % Velocity command (time-derivative of position)
    cmdVelocity = freq * amp * cos( freq * t );

    % Update set points
    cmd.position = cmdPosition;
    cmd.velocity = cmdVelocity;
    group.send