Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
GoogleCodeExporter opened this issue Mar 18, 2016 · 5 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

Looking into this issue.

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

  • Changed state: Started

@GoogleCodeExporter
Copy link
Author

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

@GoogleCodeExporter
Copy link
Author

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

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

This issue was closed by revision r476.

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

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant