In MATLAB I'm using a couple of java routines I've written to interface with a MyQSL database. One routine returns a boolean value
result <1x1 java.lang.Boolean>
>> result
result =
true
When I then use it in a conditional statement I get an error message.
>> if result,
disp('result is true')
end
??? Conversion to logical from java.lang.Boolean is not possible.
Is there a way to use the java boolean class as a MATLAB logical type? Or do I have to resort to returning integer values from my java routines?
L = logical( A ) converts A into an array of logical values. Any nonzero element of A is converted to logical 1 ( true ) and zeros are converted to logical 0 ( false ). Complex values and NaNs cannot be converted to logical values and result in a conversion error.
-by- szN array of logical ones where sz1,...,szN indicates the size of each dimension. For example, true(2,3) returns a 2-by-3 array of logical ones. T = true(___,'like', p ) returns an array of logical ones of the same sparsity as the logical variable p using any of the previous size syntaxes.
Example:
b = java.lang.Boolean(true);
if b.booleanValue
disp('val is true')
else
disp('val is false')
end
And to make sure:
>> v = b.booleanValue;
>> whos v
Name Size Bytes Class Attributes
v 1x1 1 logical
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With