I have a problem.m file that has a function like this: myfun(p,m)
.
It does some calculation and returns the result. For testing the execution of this function I have a test.m file that looks like this.
myfun(myarg1,myarg2)
If I run this file as:
octave test.m
Then it returns me the correct result which looks like this : 0.38007
Now, the problem is when calling this function myfun(p,m) using python. I tried to use python library : oct2py
The python code looks like this:
import sys
import subprocess
import oct2py
import requests
from oct2py import octave
def myfun(p,m):
octave.addpath('/mypath');
oc = oct2py.Oct2Py()
#res = octave.myfun(p,m nout=1);#this didn't work, hence comment
#res = oc.myfun(p, m) #this didn't work, hence comment
x = oc.feval("myfun",p,m);
print(x);
if __name__ == '__main__':
myfun(sys.argv[1],sys.argv[2])
When i run this code as: python FileName.py arg1 arg2 (same arguments i used in test.m) , it gives me a warning message and an empty list like this :
warning: some elements in list of return values are undefined []
I am not sure what to do about this. As the function seems to be returning correct result in a correct format when using octave. but for some reason oct2py is not working.