rsmenon / MATLink

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

error in MFunction with "OutputArguments" larger than 19 [OSX+Mathematica10] #75

Closed sunt05 closed 10 years ago

sunt05 commented 10 years ago

I have a Matlab-based function PUCM that works well under Matlab 2012a. By default, PUCM under Matlab should have an output of size as 30.

The problem is: When I call PUCM with MFuntion["PUCM","OutputArguments"->20], the error occurs as follows: "MATLink::errx: Undefined function or variable 'ZrFXJhEdSqtsInkWOMpUYGLCwxgfvoHBDjTybmeVNAluKi'." However, once the "OutputArguments" is decreased to a number less than 20, say 18, everything works as fine as usual.

I'm wondering if there's any internal error with MATLink.

szhorvat commented 10 years ago

Using 30 output arguments sounds rather unusual. Is there any reason why you coulnd't just return the result in a single array or cell?

sunt05 commented 10 years ago

In fact the Matlab function PUCM was designed to be re-utilized by other functions and the multiple-output convention will other functions' lives easier. Your suggest does sound a good workaround I will try. However, I'm still wondering why MATLink fails to retrieve multiple outputs by an MFunction.

szhorvat commented 10 years ago

Actually I was not able to reproduce this problem when I tried with 21 output arguments. Please give a complete minimal example that shows the problem and also append the output of MATLinkDeveloperGetInfo[].

szhorvat commented 10 years ago
In[12]:= myfun = MFunction["myfun",
  "function [a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21] = myfun(x)
  a1=x
  a2=x
  a3=x
  a4=x
  a5=x
  a6=x
  a7=x
  a8=x
  a9=x
  a10=x
  a11=x
  a12=x
  a13=x
  a14=x
  a15=x
  a16=x
  a17=x
  a18=x
  a19=x
  a20=x
  a21=x
  end", "OutputArguments" -> 21, "Overwrite" -> True] 

Out[12]= MFunction["myfun", "OutputArguments" -> 21]

In[13]:= myfun[3]
Out[13]= {3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3., 3.}

In[14]:= Length[%]
Out[14]= 21
szhorvat commented 10 years ago

Closing as un-reproducible. If you have a reproducible minimal example, please post it.