sto_user
sto_user

Reputation: 31

Convert uint16 Matlab matrix into a Java short[][] using jmatio?

I am trying to convert a uint16 Matlab matrix (size: 1109-by-1024) into a Java short[][] using the jmatio library. Following is the code:

String name     = "array_re";
String fileName = "microsec.mat";
MatFileReader matfilereader = new MatFileReader( fileName );
short[][] mlArrayShort = ((MLInt16) matfilereader.getMLArray( name  
                          )).getArray();

However, at the third line, I am getting the following error:

"com.jmatio.io.MatlabIOException: Incorrect matlab array class: uint16".

Does anyone know how to resolve this?

Upvotes: 0

Views: 205

Answers (1)

sto_user
sto_user

Reputation: 31

Thank you so much for your answers. Yes the problem was that Java does not handle unsigned data types. I converted the matrix from Matlab to signedint16 and read it in Java successfully using the same above code.

Upvotes: 0

Related Questions