MATLAB: Help with MuPAD function (stats::covariance) error at Matlab

advanced symbolic toolboxadvanced symbolicserrorMATLAB

My code is below. Could you help me to avoid the below error?
syms x1 y1 x2 y2;
z=feval(symengine,'stats::covariance',[x1, y1],[x2, y2]);
>> ex
Error using mupadengine/feval (line 163)
Some data are of invalid type.
Error in ex (line 2)
z=feval(symengine,'stats::covariance',[x1, y1],[x2, y2]);

Best Answer

This requires an advanced symbolic toolbox trick.
symLIST = @(varargin)feval(symengine,'DOM_LIST',varargin{:});
syms x1 y1 x2 y2
z = feval(symengine, 'stats::covariance', symLIST(x1, y1), symLIST(x2, y2));
when you see a MuPAD call documented with [] around the argument, then that is a DOM_LIST argument and you have to construct that specially from MATLAB. When you try to use normal [] list and pass that to MuPAD then what gets passed is DOM_MATRIX