The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::Matlab::Remote - Interface to a remote Matlab process.

SYNOPSIS

  use Math::Matlab::Remote;
  $matlab = Math::Matlab::Remote->new({
      uri     => 'https://server1.mydomain.com',
      timeout => 300,
      user    => 'me',
      pass    => 'my_password'
  });
  
  my $code = q/fprintf( 'Hello world!\n' );/
  if ( $matlab->execute($code) ) {
      print $matlab->fetch_result;
  } else {
      print $matlab->err_msg;
  }

DESCRIPTION

Math::Matlab::Remote implements an interface to a remote Matlab server (see Math::Matlab::Server). It uses the LWP package to access the server via the HTTP protocol. The Remote object has the URI of the server, a timeout value for the requests and a user name and password used for basic authentication of the request.

The URI specifies the server to pass the request to along with some optional PATH_INFO which is prepended to the relative Matlab working directory passed through the exectute() method. The server has it's own Math::Matlab object (typically Local or Pool), which it uses to perform the computation and send back the resulting raw output.

E.g. If a server is set up with it's base URL at 'http://my.server.com/matlab/', corresponding to a Math::Matlab::Local object with root_mwd '/opt/matlab-server', then passing 'bar' as the relative Matlab working directory to the execute() method of a Remote whose uri field is set to 'http://my.server.com/matlab/foo' will cause the Local object on the server to attempt to change to the directory '/opt/matlab-server/foo/bar' before attemptting to exectute the code.

Attributes

uri

A string containing the URI of the corresponding Matlab server (see Math::Matlab::Server). Any PATH_INFO in the URI beyond the root URI of the server will be prepended to the relative Matlab working directory passed through the exectute command.

The default is taken from the package variable $URI.

timeout

The maximum time the remote should wait for a response from the server (in seconds) before giving up. The default is taken from the package variable $TIMEOUT, whose default value is 300.

user

A string containing the user name to use for basic authentication when making a request to the server. The default is taken from the package variable $USER.

pass

A string containing the password to use for basic authentication when making a request to the server. The default is taken from the package variable $PASS.

METHODS

Public Class Methods

new
 $matlab = Math::Matlab::Remote->new;
 $matlab = Math::Matlab::Remote->new( {
    uri     => '/usr/local/matlab -nodisplay -nojvm',
    timeout => '/root/matlab/working/directory/'
    user    => 'me',
    pass    => 'my_password'
 } )

Constructor: creates an object which can run Matlab programs and return the output. Attributes 'uri', 'timeout', 'user' and 'pass' can be initialized via a hashref argument to new(). Defaults for these values are taken from the package variables $URI, $TIMEOUT, $USER and $PASS, respectively.

Public Object Methods

execute
 $TorF = $matlab->execute($code)
 $TorF = $matlab->execute($code, $relative_mwd)

Takes a string containing Matlab code and sends it to a Matlab server (see Math::Matlab::Server) for execution. It stores the returned result in the object. The optional second argument specifies the Matlab working directory relative relative to the URI being accessed. Returns true if successful, false otherwise.

uri
 $uri = $matlab->uri
 $uri = $matlab->uri($uri)

Get or set the URI attribute.

timeout
 $timeout = $matlab->timeout
 $timeout = $matlab->timeout($timeout)

Get or set the timeout value.

user
 $user = $matlab->user
 $user = $matlab->user($user)

Get or set the user for basic authentication of server request.

pass
 $pass = $matlab->pass
 $pass = $matlab->pass($pass)

Get or set the password for basic authentication of server request.

CHANGE HISTORY

  • 10/16/02 - (RZ) Created.

COPYRIGHT

Copyright (c) 2002 PSERC. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

  Ray Zimmerman, <rz10@cornell.edu>

SEE ALSO

  perl(1), Math::Matlab