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

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]);

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 2 Mär. 2017
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

2 Kommentare

Dear Walter Roberson; Thank you very much. Based on your answer, I changed my code a bit. But again, I have an error message. Could you help me figure out what's wrong? Thank you in advance!
symMATRIX= @(varargin)feval(symengine,'DOM_MATRIX',varargin{:});
syms m x;
r1=normrnd(0,1,[1,2]);
r2=normrnd(0,1,[1,2]);
x1=m*r1;
y1=x*r2 + m*r1;
z = feval(symengine, 'stats::covariance', symMATRIX(x1), symMATRIX(y1));
>>
Error using mupadengine/feval (line 163)
The number of data is incorrect.
Error in ex1 (line 8)
z = feval(symengine, 'stats::covariance', symMATRIX(x1), symMATRIX(y1));
you need to use DOM_LIST for the interference

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by