%sFtpDisconnect 
%disconnects Matlab from a remote machine
% 
%in -----------------------------------------------------------------------
%  sFtpClient:  a Java SFTPv3Client object (instance of sftp client class)
%  channel:     is the Java ChannelShell object to connect
%
%out-----------------------------------------------------------------------
%  sFtpClient:  a Java SFTPv3Client object (instance of sftp client class)
%  channel:     is the Java ChannelShell object to connect
%##########################################################################

function [sFtpClient, channel] = sFtpDisconnect(sFtpClient, channel)

  if(nargin  ~=  2)
    error('Error: sFtpDisconnect requires two input arguments...');
  end

%  Disconnect the Java object using the java method if it is of the correct
%  class, if not quit with an error

  if(isa(sFtpClient,'ch.ethz.ssh2.SFTPv3Client'))
    sFtpClient.close(); 
  else
    error(['Error: sFtpDisconnect input argument sFtpClient is'...
      ' not a sFtpClient object...']); 
  end
 
  if(isa(channel,'ch.ethz.ssh2.Connection'))
    channel.close();
  else
    error(['Error: sFtpDisconnect input argument channel is'...
      ' not a Java Connection object...']);
  end