teocci / matlabcontrol

Automatically exported from code.google.com/p/matlabcontrol
0 stars 1 forks source link

Cannot use getNumericArray on an array of complex numbers in MATLAB #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What version of matlabcontrol are you using?
Release version: 4.0.0

What version of MATLAB are you using?
2011a 64-bit

What operating system are you using?
Windows 7 64-bit

Are you using matlabcontrol from inside MATLAB or outside MATLAB?
Outside in a Java application

What steps will reproduce the problem?
1. Run this code:

MatlabProxyFactoryOptions MATLABOptions = new 
MatlabProxyFactoryOptions.Builder().setHidden(true).build();
MatlabProxyFactory factory = new MatlabProxyFactory(MATLABOptions);
MatlabProxy proxy = null;
MatlabTypeConverter converter = null;
try
{
    proxy = factory.getProxy();
    converter = new MatlabTypeConverter(proxy);
    proxy.eval("a = [1+1i;2+2i;3+3i];");
    double[][] arrayRealValues = converter.getNumericArray("a").getRealArray2D();
    double[][] arrayImagValues = converter.getNumericArray("a").getImaginaryArray2D();
}
catch (Exception e)
{
    System.err.println(e);
}  

What did you expect to happen? What happened instead?
Expected to be able to access the variable in matlab without throwing an 
exception. The following message/exception was displayed instead:

"matlabcontrol.MatlabInvocationException: RuntimeException occurred in 
MatlabThreadCallable, see cause for more information"

The cause was indicated as: "java.lang.ClassCastException: [Ljava.lang.Object; 
cannot be cast to [D"

Please provide any additional information below.

Note that the above program works perfectly if accessing a real valued 
variable, i.e. if the eval line was adjusted to "proxy.eval("a = [1;2;3];");", 
and the getImaginaryArray2D command was removed.

Original issue reported on code.google.com by ryan.van...@gmail.com on 24 Oct 2011 at 9:07

GoogleCodeExporter commented 9 years ago
Looking into this issue.

Original comment by nonot...@gmail.com on 27 Oct 2011 at 3:08

GoogleCodeExporter commented 9 years ago

Original comment by nonot...@gmail.com on 27 Oct 2011 at 3:08

GoogleCodeExporter commented 9 years ago

Original comment by nonot...@gmail.com on 26 Feb 2012 at 9:45

GoogleCodeExporter commented 9 years ago
Don't know if this is still and issue but there was a bug in the 
MatlabTypeConverter in thye "call" method
Line 90 was missing the array index at the end
Should read
Object imaginaryObject = proxy.returningEval("imag(" + _arrayName + ");", 1)[0];
not
Object imaginaryObject = proxy.returningEval("imag(" + _arrayName + ");", 1);

Original comment by Derrick....@gmail.com on 3 Oct 2012 at 5:03

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r476.

Original comment by nonot...@gmail.com on 18 Feb 2013 at 8:11