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: POE2DH.m
    path of file: ./repos/Robotics-Toolbox/rvcdlcs/src/thirdparty/dh2poe
    
    the code of the file until where you have to start completion: function DH_par = POE2DH (POE_par)
%POE2DH Conversion from POE parameters to DH parameters
%
%   DH_par = POE2DH (POE_par)
%   POE_par:    POE parameters, 6 x n+1
%   DH_par:     DH parameters,  n+2 x 4  

n=size(POE_par,2)-1; %number of joints 

DH_par = zeros(n+2, 4);

xi = POE_par(:,1);

g = eye(4);

for i=1:n

[theta, d, alpha, a]=POE2DH_Joint (xi);


    
function DH_par = POE2DH (POE_par)
%POE2DH Conversion from POE parameters to DH parameters
%
%   DH_par = POE2DH (POE_par)
%   POE_par:    POE parameters, 6 x n+1
%   DH_par:     DH parameters,  n+2 x 4  

n=size(POE_par,2)-1; %number of joints 

DH_par = zeros(n+2, 4);

xi = POE_par(:,1);

g = eye(4);

for i=1:n

[theta, d, alpha, a]=POE2DH_Joint (xi);

DH_par(i,:) = [theta, d, alpha, a];

g = g*DH (DH_par(i,:),'std');

if i~=n
    xi = adM(inv(g))*POE_par(:,i+1);
end