[Forwarding to r-help for completeness. /Henrik] ---------- Forwarded message ---------- From: Henrik Bengtsson <[EMAIL PROTECTED]> Date: Dec 28, 2006 9:45 PM Subject: Re: [R] Query regarding linking R with Matlab To: [EMAIL PROTECTED]
Hi. On 12/28/06, Bhanu Kalyan.K <[EMAIL PROTECTED]> wrote: > Respected Sir, > I am sorry that i forgot to 'setVerbose'. Now when that is set, The result > is: > > > Matlab$startServer(minimize=FALSE) > [1] 0 > > > matlab <- Matlab(host="localhost") > > > open(matlab) > [1] TRUE > > > setVerbose(matlab, -2) > > > res <- evaluate(matlab, "A=1+2;", "B=ones(2,20);") > > Sending expression on the Matlab server to be evaluated...: 'A=1+2; > B=ones(2,20);' > Received an 'OK' reply (0) from the Matlab server. > Evaluated expression on the Matlab server with return code 0. > > > res > NULL > > > close(matlab) > Closing connection to host 'localhost' (port 9999)... > Received an 'OK' reply (0) from the Matlab server. > Closing connection to host 'localhost' (port 9999)...done > > What should "res" object contain finally when we are doing > res <- evaluate(matlab, "A=1+2;", "B=ones(2,20);") ?? The return value of evaluate() is NULL when successful (I noticed the help is saying '0'; I've corrected that for the next version). Anyway, 'res' contains nothing of interest. If there is any error on the Matlab side, an error is thrown in R giving you the details. What you might want to do is: data <- getVariable(matlab, "A") str(data) > > once i do > close(matlab), the matlab server is shutdown, Yes, the server script is shut down, but Matlab is left running on purpose so you have a chance to continue working with the Matlab session by hand. > However, when i ask for the > values of A & B in matlab window, the output is displayed correctly. The > matlab window outputs thus: > » A > > A = > > 3 > > » B > > B = > > Columns 1 through 17 > > 1 1 1 1 1 1 1 1 1 1 1 1 > 1 1 1 1 1 > 1 1 1 1 1 1 1 1 1 1 1 1 > 1 1 1 1 1 > > Columns 18 through 20 > > 1 1 1 > 1 1 1 > > What do you interpret? That everything is now working as expected. See the example of help(Matlab) to get more ideas how to interact with Matlab from R. Cheers Henrik > Kindly let me know > > > Regards > Bhanu Kalyan K > > > Bhanu Kalyan K > BTech CSE Final Year > [EMAIL PROTECTED] > Tel :+91-9885238228 > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com ______________________________________________ R-help@stat.math.ethz.ch 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.