[R] R.matlab package help

Henrik Bengtsson hb at stat.berkeley.edu
Fri Aug 27 21:12:23 CEST 2010


Hi,

could you send me what Matlab is outputting.  When I send the following from R:

> evaluate(matlab, "A=2;");
Sending expression on the Matlab server to be evaluated...: 'A=2;'

and Matlab should print something like:

Received cmd: 1
"eval" string: "A=2;"
Received an 'OK' reply (0) from the Matlab server.
Evaluated expression on the Matlab server with return code 0.
Sent byte: 0

I'm really interested to see what that "eval" string line looks like
just before you get the error.

/Henrik

On Fri, Aug 27, 2010 at 9:38 AM, michael <tufemichael at gmail.com> wrote:
> Henrik,
>           Thanks for your reply. I am using Matlab version
> 7.9.0(R2009b). This is my first try using R.matlab. I started matlab
> in the same machine, and I run the MatlabServer.m in matlab, here is
> my code in R:
>
> library(R.matlab)
> library(MASS)
> matlab <- Matlab()
> open(matlab)
> setVerbose(matlab, -2)
> setOption(matlab, "readResult/interval", 10);
> setOption(matlab, "readResult/maxTries", 30*(60/10));
>
> y<-matrix(rnorm(100),100,1)
> x<-matrix(rnorm(200),100,1)
> z<-matrix(rnorm(200),100,2)
>
> setVariable(matlab, y=y,remote=FALSE)
> setVariable(matlab, x=x,remote=FALSE)
> setVariable(matlab, z=z,remote=FALSE)
> evaluate(matlab,"B=TSLS(y,x,z);")
> evaluate(matlab,"B")
> B <- getVariable(matlab, "B",remote=FALSE)
>
>
> where TSLS is a matlab function that is already written and sitting in
> the working folder. The code works fine until the last command,
> getVariable function, where it returns an error:
>
> ??? Error: A MATLAB string constant is not terminated properly.
>
> Error in ==> MatlabServer at 197
>      eval(expr);
>
> In R:
>   Retrieving variables from the Matlab server: 'B'
>   Sending expression on the Matlab server to be evaluated...:
> 'variables = {'B'};'
>   Received an 'OK' reply (0) from the Matlab server.
>   Evaluated expression on the Matlab server with return code 0.
>   Asks the Matlab server to send variables via the local file system...
>   Error in file(con, open = "rb") : invalid 'description' argument
>
>
> Thanks,
>
> Michael
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list