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: direct_combine_pots.m
    path of file: ./repos/bnt/BNT/potentials/@scgpot
    
    the code of the file until where you have to start completion: function pot = direct_combine_pots(pot1, pot2)
% DIRECTED_COMBINE_POTS The combination operation corresponds to ordinary composition of conditional distributions. 
% In some sense is similar to that of forming disjoint union of set.
% pot = direct_combine_pots(pot1, pot2)

% directed combine can be performed under the conditon that the head node set of pot1 is disjoint from the domain of 
% pot2 or vice versa. if the last conditon was satisfied we exchange the pot1 and pot2 firstly then perform the operation.
% If neither of them was satified the directed combine is undifined.


    
function pot = direct_combine_pots(pot1, pot2)
% DIRECTED_COMBINE_POTS The combination operation corresponds to ordinary composition of conditional distributions. 
% In some sense is similar to that of forming disjoint union of set.
% pot = direct_combine_pots(pot1, pot2)

% directed combine can be performed under the conditon that the head node set of pot1 is disjoint from the domain of 
% pot2 or vice versa. if the last conditon was satisfied we exchange the pot1 and pot2 firstly then perform the operation.
% If neither of them was satified the directed combine is undifined.


if isempty( myintersect(pot1.domain, pot2.cheaddom) )
    pot1 = pot1;
    pot2 = pot2;
elseif  isempty( myintersect(pot2.domain, pot1.cheaddom))
    temppot = pot1;
    pot1 = pot2;
    pot2 = temppot;
else
    assert(0);
    return;
end