I have a main python script and I want to call a Matlab function (spm_filter.m) on an array.
I use something like the following:
import matlab.engine
eng = matlab.engine.start_matlab()
y_filtered = np.asarray(eng.spm_filter(filter_kernel, matlab.double(data.tolist()) ,nargout=1))
This works fine but it is extremely slow compared to the case where I use only Matlab to do the same thing e.g. by doing:
y_filtered = spm_filter(filter_kernel, data)
Why is the matlab engine so slow? How can I make it faster?
I do not time the start of the engine. It seems that the slow down is coming due to matlab.double(data.tolist()
. Any way to improve this part?