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: checkpath.m
    path of file: ./repos/segment-open/source
    
    the code of the file until where you have to start completion: function checkpath(pathname)
%Ensures that the pathname for Segment is on matlab's path. This is utilized in
%initialize to ensure that the Segment root directory in on the search
%path.

%Einar Heiberg

    
function checkpath(pathname)
%Ensures that the pathname for Segment is on matlab's path. This is utilized in
%initialize to ensure that the Segment root directory in on the search
%path.

%Einar Heiberg

global DATA

if isdeployed()
 
  %Check if in correct path
  if iscorrectpath(pathname)
    return;
  end
  
  %--- Ok. Not correct look in program files
  programfilesdir = getenv('programfiles');
  
  programnamenospace = DATA.ProgramName;
  programnamenospace = programnamenospace(programnamenospace~=' ');
  
  softwarepath = [programfilesdir filesep 'Medviso' filesep programnamenospace filesep 'application'];
  if iscorrectpath(softwarepath)
    %Found it change path to this folder
    cd(softwarepath);
    return
  end