Skip to content

Evaluating Entire Matlab code at a time

3 messages · Henrik Bengtsson, Bhanu Kalyan.K

#
Hi.
On 12/30/06, Bhanu Kalyan.K <kalyansikha at yahoo.com> wrote:
To me this looks like Matlab can't find those commands, and then it
has nothing to with R. Make sure your Matlab scripts are available in
the Matlab path or in the working directory of Matlab.  You check the
working directory of Matlab with:

 evaluate(matlab, "pwd=cd();");
 pwd <- getVariable(matlab, "pwd")$pwd;
 print(pwd);

Check to see if your scripts are in the working directory:

 evaluate(matlab, "files=dir();")
 files <- getVariable(matlab, "files")$files
 unlist(files["name",,])

If not, you have to update your Matlab path or change the working directory.

Hope this helps

Henrik
#
This is very odd, but maybe 'cd' is not a command on your Windows
Matlab installation.  I tried the same code on a Unix installation (I
don't have access to Matlab for Windows but others have been using
R.matlab there successfully).  Find out what the command for getting
the current directory in your Matlab version is and use that instead.

You could also troubleshoot by this:

1. Start Matlab using Matlab$startServer(minimize=FALSE)
2. Setup the Matlab connection from R and close it with close(matlab).
3. Go to the Matlab windows and try the commands that failed for you
    when called from R. This will give you a hint.

Remember, there is nothing magic going on.  Think about the R Matlab
connection as R is typing the Matlab commands for you; anything you
can do in that Matlab windows which you did close(matlab) on you can
do with evaluate(matlab, ...) - before closing it that is.

/Henrik
On 12/30/06, Bhanu Kalyan.K <kalyansikha at yahoo.com> wrote: