rsmenon / MATLink

Communicate with MATLAB from Mathematica
matlink.org
68 stars 14 forks source link

MATLink launch matlab, but without environment (workspace, command window,...) #85

Closed emac379 closed 8 years ago

emac379 commented 8 years ago

Hello,

I just installed MATLink on my Mac (OS X Yosemite), but I am running to the following two issues.

1- I could not get it to work with Matlab 2015a. OpenMatlab[] fails....

2- I went back to my old Matlab 2011a and it seemed to work. However, OpenMalab[] launches MATLAB 2011a without the full environment (desktop). So I do not see any of the Matlab environment such as Workpace, Command Window, Command History, Current Folder, etc,...

I basically only see a large Matlab window, with "MATLAB" in the left top corner that pull down to the typical menu: "about Matlab", "Preferences", "Services", etc,...

The strange thing is that I can actually do the examples and MATLink seems to allow me to use Matlab functions, but I do not have a Workspace nor Command window in the Matlab environment.

Any explanation for this issue will be greatly appreciated.

How can I actually address it ?

I only have Matlab 2011a installed in the /Applications so I suspect it is not due to the fact that I have two version of Matlab on the machine.

Thanks!

rsmenon commented 8 years ago

Thanks for the report.

Re: 1. What was the exact message you got (if any)? Or did it just hang? MATLink should work with MATLAB 2015a, so we'll need more information to resolve this. A few followup questions:

Please also see the "Executing OpenMATLAB[] simply hangs" section on our troubleshooting page, and the "Necessary steps" above it.

If the issue still persists, could you please also post the output of MATLinkDeveloperGetInfo[]?

Re: 2. Unfortunately, this is how MATLink works currently and this is fundamentally due to the limitations of the MATLAB Engine. We can run MATLAB only in a "headless" mode, meaning, you won't have the workspace/editor/command history, etc. On Windows, you can do CommandWindow["Show"] via MATLink to open up a MATLAB command window, but this feature does not exist on Linux and OS X (again, due to the limitations of the MATLAB engine).

emac379 commented 8 years ago

Thanks for the prompt reply!

For Re:1 It just said that "Failed". This is actually the first time I installed MATLink (a very pleasant finding for me) and did not install the 32-bit version. Also, Matlab 2015a was installed at the default location /Applications. I do have to admit that I have not tried much to troubleshoot and quickly jumped to get my Matlab 2011a back from the trash. I will try again with 2015 a and provide you with more details if it does not work ...

For Re:2 It is good to know that this normal operation due to limitation of the Matlab Engine instead of an installation issue. I do have some follow up questions as I came across MATLink because I was trying to export data from Mathematica to Matlab, which should be represented as a cell (an array with x coordinates, y coordinates, and a 2X2 matrix anisotropic material property associated with each (x,y) coordinate pair).

My intend is to save this data in a cell and do some processing on it in Matlab (interpolation of the tensor material property) to use with a finite element code (Comsol). So my question are the following:

  1. Am I limited to use Matlab commands only the Mathematica environment?
  2. Could I save the cell arrays as a .mat file using Mathematica and just open a new Matlab session to proceed on ?

The trivial solution seems to be the second one, but I am very new to MATLink and I did notice that I could not get another Matlab session started.

Thanks again for your response and for developing this very helpful and needed interface between Mathematica and Matlab:-)

szhorvat commented 8 years ago

For Re:1

I have used MATLAB R2015a with MATLink on Yosemite and it worked fine. About the only thing I think of that would prevent MATLink from working is if MATLAB is not installed at the default location and under the default name (i.e. MATLAB_R2015a.app).

  1. Am I limited to use Matlab commands only the Mathematica environment?

Yes.

When using MATLink, MATLAB runs in a special mode where the command window is not accessible.

  1. Could I save the cell arrays as a .mat file using Mathematica and just open a new Matlab session to proceed on ?

Yes, you can use MATLink to save the data to a .mat file, then re-import it in a standard MATLAB session. Without MATLink it is not possible to export a cell array from Mathematica.

szhorvat commented 8 years ago

@rsmenon 32-bit versions of MATLAB aren't available at all on OS X (fortunately, as this means we don't have to support them with MATLink ...)

rsmenon commented 8 years ago

@szhorvat Ah yes, I forgot about that!

rsmenon commented 8 years ago

@emac379

I did notice that I could not get another Matlab session started.

Technically, you can open another session of MATLAB if your license allows it (and most university/site licenses do). On OS X, you cannot launch it by clicking on the icon again, but you can start it from the terminal like so:

open -n /Applications/MATLAB_R2011a.app

or by executing the binary directly:

/Applications/MATLAB_R2011a.app/bin/matlab

Am I limited to use Matlab commands only the Mathematica environment?

Yes, they have to be valid MATLAB commands, but if you have 3rd party applications/toolboxes that interface with MATLAB (like COMSOL or CVX), then you can use them by adding the appropriate paths to your MATLAB session running via MATLink.

szhorvat commented 8 years ago

I did notice that I could not get another Matlab session started.

An addendum to what @rsmenon said: if you start MATLAB first, and run OpenMATLAB[] only after, then it won't be necessary to use the open command from a terminal.

R2015a

What I forgot to say is that if you try again and it doesn't work, please send us the output of the command

Needs["MATLink`"]
MATLink`Developer`GetInfo[]