diff --git a/pymatbridge/matlab/matlabserver.m b/pymatbridge/matlab/matlabserver.m index 9e20c1e..8fa7507 100644 --- a/pymatbridge/matlab/matlabserver.m +++ b/pymatbridge/matlab/matlabserver.m @@ -20,18 +20,15 @@ function matlabserver(socket_address) break; case {'run_function'} - fhandle = str2func('pymat_feval'); - resp = feval(fhandle, req); + resp = pymat_feval(req); messenger('respond', resp); case {'run_code'} - fhandle = str2func('pymat_eval'); - resp = feval(fhandle, req); + resp = pymat_eval(req); messenger('respond', resp); case {'get_var'} - fhandle = str2func('pymat_get_variable'); - resp = feval(fhandle, req); + resp = pymat_get_variable(req); messenger('respond', resp); otherwise diff --git a/pymatbridge/matlab/usrprog/demo_func.m b/pymatbridge/matlab/usrprog/demo_func.m index f0b6239..394841b 100644 --- a/pymatbridge/matlab/usrprog/demo_func.m +++ b/pymatbridge/matlab/usrprog/demo_func.m @@ -1,5 +1,4 @@ -function res = test(args) -% demonstration function; formerly known as 'test.m' +function res = demo_func(args) res = args.a + 1; figure diff --git a/pymatbridge/matlab/usrprog/precision_divide.m b/pymatbridge/matlab/usrprog/precision_divide.m index 6948cc9..0e16d5c 100644 --- a/pymatbridge/matlab/usrprog/precision_divide.m +++ b/pymatbridge/matlab/usrprog/precision_divide.m @@ -1,4 +1,4 @@ -function res = test_precision_divide(args) +function res = precision_divide(args) % This function devides val1 by val2 and returns the result res = args.val1 / args.val2; diff --git a/pymatbridge/matlab/usrprog/precision_multiply.m b/pymatbridge/matlab/usrprog/precision_multiply.m index 11557f5..1c12f23 100644 --- a/pymatbridge/matlab/usrprog/precision_multiply.m +++ b/pymatbridge/matlab/usrprog/precision_multiply.m @@ -1,4 +1,4 @@ -function res = test_precision_multiply(args) +function res = precision_multiply(args) % This function returns the product of two arguments val1 and val2 res = args.val1 * args.val2; diff --git a/pymatbridge/matlab/usrprog/precision_pass.m b/pymatbridge/matlab/usrprog/precision_pass.m index afc57bd..1225c1c 100644 --- a/pymatbridge/matlab/usrprog/precision_pass.m +++ b/pymatbridge/matlab/usrprog/precision_pass.m @@ -1,4 +1,4 @@ -function res = test_precision_pass(args) +function res = precision_pass(args) % This function takes an argument val and simply return it res = args.val; diff --git a/pymatbridge/matlab/usrprog/precision_sqrt.m b/pymatbridge/matlab/usrprog/precision_sqrt.m index c6a4e35..ef87cf0 100644 --- a/pymatbridge/matlab/usrprog/precision_sqrt.m +++ b/pymatbridge/matlab/usrprog/precision_sqrt.m @@ -1,4 +1,4 @@ -function res = test_precision_sqrt(args) +function res = precision_sqrt(args) % This function returns the square root of the value res = sqrt(args.val); diff --git a/pymatbridge/matlab/usrprog/precision_sum.m b/pymatbridge/matlab/usrprog/precision_sum.m index ce0528c..6d6bd45 100644 --- a/pymatbridge/matlab/usrprog/precision_sum.m +++ b/pymatbridge/matlab/usrprog/precision_sum.m @@ -1,4 +1,4 @@ -function res = test_precision_sum(args) +function res = precision_sum(args) % This function returns the sum of two arguments val1 and val2 res = args.val1 + args.val2; diff --git a/pymatbridge/matlab/util/pymat_eval.m b/pymatbridge/matlab/util/pymat_eval.m index 510d753..64d081b 100644 --- a/pymatbridge/matlab/util/pymat_eval.m +++ b/pymatbridge/matlab/util/pymat_eval.m @@ -1,14 +1,13 @@ -function json_response = web_eval(req); -%WEB_EVAL: Returns a json object of the result of calling the function +function json_response = pymat_eval(req); +% PYMAT_EVAL: Returns a json object of the result of calling the function % -% json_response = WEB_EVAL(headers); -% json_response = WEB_EVAL(headers, config); +% json_response = pymat_eval(req); % -% This allows you to run any matlab code. To be used with webserver.m. -% HTTP POST to /web_eval.m with the following parameters: +% This allows you to run any matlab code. req should be a struct with the +% following fields: % code: a string which contains the code to be run in the matlab session % -% Should return a json object containing the result +% Should return a json object containing the result. % % Based on Max Jaderberg's web_feval diff --git a/pymatbridge/matlab/util/pymat_feval.m b/pymatbridge/matlab/util/pymat_feval.m index 137abcb..9a74e13 100644 --- a/pymatbridge/matlab/util/pymat_feval.m +++ b/pymatbridge/matlab/util/pymat_feval.m @@ -1,6 +1,6 @@ % Max Jaderberg 2011 -function json_response = matlab_feval(req) +function json_response = pymat_feval(req) response.success = 'false'; field_names = fieldnames(req); diff --git a/pymatbridge/pymatbridge.py b/pymatbridge/pymatbridge.py index 1c5a1fb..8b52d56 100644 --- a/pymatbridge/pymatbridge.py +++ b/pymatbridge/pymatbridge.py @@ -170,7 +170,7 @@ def is_connected(self): return False def is_function_processor_working(self): - result = self.run_func('%s/test_functions/test_sum.m' % MATLAB_FOLDER, + result = self.run_func('%s/usrprog/test_sum.m' % MATLAB_FOLDER, {'echo': '%s: Function processor is working!' % self._program_name()}) return result['success'] == 'true'