MATLAB.jl icon indicating copy to clipboard operation
MATLAB.jl copied to clipboard

Better anticipate Matlabs behavior regarding integer vs float values?

Open Naikless opened this issue 1 year ago • 0 comments

This took me a while to figure out:

If I send data from Julia to Matlab, integer values from Julia will be cast as the corresponding integer values in Matlab. However, using Integer values in Matlab is relatively rare as per default everything is a double.

This can lead to some unexpected errors, because Matlab e.g. refuses to compute something like this:

[int64(1) int64(2)] .* [2,3]
Error using  .* 
Integers can only be combined with integers of the same class, or scalar doubles.

Not sure what the best solution here would be though. At the very least I would stress in the readme that every Julia variable that is supposed to be used by Matlab should be defined as a float, i.e. 1.0 instead of 1 unless the Matlab code specifically asks for integers.

Naikless avatar Jun 20 '23 10:06 Naikless