So as a dedicated answer to the OP question (initially it was necessary to re-compile the mex file messenger.mexw64 for windows 10 [see the original post comments]):
Ok, now it's works, but i have a problem, when i print 'res' in pycharm, i have this "{'result': '', 'success': False, 'content': {'stdout': 'Too many input arguments.'}}"
In your matlab function you stated only one argument:
function lol = yourfunc(args)
But when you call it in python you are calling it with two input arguments (arg1 & arg2):
res = mlab.run('...path\yourfunc.m', {'arg1': 3, 'arg2': 5})
In the matlab function input you are assuming it is a data structure with at least the two fields arg1 & arg2; you are referencing these variables from the structure when you call
args.arg1
args.arg2
As I am not sure if you can pass a data structure this technique (as a JSON style string input from a python function) I would propose changing the input arguments to the Matlab function to either:
Change your function to support two arguments like how you are calling it from python:
%% MATLAB
function lol = yourfunc(input1,input2)
arg1 = input1;
arg2 = input2;
lol = arg1 + arg2;
end
# PYTHON (just to be clear)
from pymatbridge import Matlab
mlab = Matlab()
mlab.start()
res = mlab.run('...path\yourfunc.m', {'input1': 3, 'input2': 5})
print(res['result'])
Or if you want to handle an infinite number of inputs (using varargin):
%% MATLAB
function lol = yourfunc(varargin)
arg1 = varargin{1};
arg2 = varargin{2};
lol = arg1 + arg2;
end
# PYTHON (just to be clear)
from pymatbridge import Matlab
mlab = Matlab()
mlab.start()
res = mlab.run('...path\yourfunc.m', {'input1': 3, 'input2': 5})
print(res['result'])
This should then remove the error message about too many input arguments and run successfully :)