[R] Query regarding linking R with Matlab

Henrik Bengtsson hb at stat.berkeley.edu
Thu Dec 28 03:16:41 CET 2006


Hi.

>From what you tell me you manage to start Matlab in the background by calling:

  Matlab$startServer()

but that R fails to connect to Matlab by:

  matlab <- Matlab(host="localhost", port=9998)
  if (!open(matlab))
    throw("Matlab server is not running: waited 30 seconds.")

Sorry for not being explicit enough; if no port is given,
Matlab$startServer() will setup up Matlab to listen to port 9999 (as
explained in the help), but then you try to communicate with it via
port 9998.  I realize that the example might be a bit confusing since
it is using port 9998 (for the purpose of illustrating the fact that
you can choose another port).

Either try the above with   Matlab$startServer(port=9998), *or*, maybe simpler:

  Matlab$startServer()
  matlab <- Matlab(host="localhost")
  if (!open(matlab))
    throw("Matlab server is not running: waited 30 seconds.")

Does this work for you?

Henrik

On 12/27/06, Bhanu Kalyan.K <kalyansikha at yahoo.com> wrote:
>
> > library("R.matlab")
> Loading required package: R.oo
> R.oo v1.2.3 (2006-09-07) successfully loaded. See ?R.oo for help.
> R.matlab v1.1.2 (2006-05-08) successfully loaded. See ?R.matlab for help.
>
> > help(Matlab)
>
> > Matlab$startServer()Loading required package: R.utils
> R.utils v0.8.0 (2006-08-21) successfully loaded. See ?R.utils for help.
> [1] 0
> // Here a Matlab window opened but that window couldnot be maximized.
>
> > matlab <- Matlab(host="localhost", port=9998)
>
> > matlab
> [1] "Matlab: The Matlab host is 'localhost' and communication goes via port
> 9998. Objects are passed via the local file system (remote=FALSE). The
> connection to the Matlab server is closed (not opened)."
>
> > setVerbose(matlab, -2)
>
> > open(matlab)
> Opens a blocked connection to host 'localhost' (port 9998)...
>  Try #0.
>  Try #1.
>  Try #2.
>  Try #3.
>  Try #4.
>  Try #5.
>  Try #6.
>  Try #7.
>  Try #8.
>  Try #9.
>  Try #10.
>  Try #11.
>  Try #12.
>
> There were 12 warnings (use warnings() to see them)
> Opens a blocked connection to host 'localhost' (port 9998)...done
>
> > if (!open(matlab))
> +   throw("Matlab server is not running: waited 30 seconds.")
> Opens a blocked connection to host 'localhost' (port 9998)...
>  Try #0.
>  Try #1.
> // I 'stopped' the computation here
> Warning message:
> localhost:9998 cannot be opened Opens a blocked connection to host
> 'localhost' (port 9998)...done
>
> This is the output obtained after running the commands. Kindly go through
> the above commands and help me identify the problem.
>
> Regards,
> Bhanu Kalyan K
>
>
> Bhanu Kalyan K
> BTech CSE Final Year
> reach4kalyan at gmail.com
> Tel :+91-9885238228
>
>  __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com



More information about the R-help mailing list