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

Better anticipate Matlabs behavior regarding integer vs float values? #211

Open
Naikless opened this issue Jun 20, 2023 · 1 comment
Open

Comments

@Naikless
Copy link

Naikless commented Jun 20, 2023

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.

@tqml
Copy link
Collaborator

tqml commented Feb 21, 2025

Hey @Naikless,

changing the default conversion to always use double for numeric types might be a cool addition.
I think it could be a preference in the MSession struct which could be checked in the pub_variable function.
Contributions definitely welcome!

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

2 participants