I’m using MATLAB to access a postgresql database. I’m running into problems trying to access a column of type boolean[]:
x;#% x is a <1x1 org.postgresql.jdbc4.Jdbc4Array>
When accessing real[] values, I can take the following approach:
double(x.getArray());
Unfortunately, with a boolean[] this leads to the following error message:
Undefined function 'toDouble' for input arguments of type 'logical'.
So I figured converting to logical first may work:
logical(x.getArray());
Except this doesn’t work either.
Error using logical
Conversion to logical from java.lang.Boolean[][] is not possible.
The problem may arise because java.lang.Boolean doesn’t derive from java.lang.Number, however the MATLAB docs on conversion of java return types make it seem like this shouldn’t be a problem.
Am I doing something wrong here? How do I get from the fetch result to a logical array usable in MATLAB? If all else fails, I can rebuild the tables with arrays of numeric types instead of boolean[], but it seems like this should be possible without going that far.
I suspect that this is due to the difference in Java between
Boolean(an object) andboolean, a primitive. Matlab conversions are really set up to handle primitives, not necessarily their associated object wrappers.I think that this conversion requires a loop, as follows: