Unexpected matlab operator Covariance

2 次查看(过去 30 天)
I'm trying to calculate the the covariance of a set of data using stats::covariance but I keep getting an error message saying 'Unexpected Matlab operator'. The code I used was:
stats::covariance([1, 2, 6, 9],[5, 9, 3, 7], Population])
I don't see the error in the code. Is there is another way of calculating the covariance?

采纳的回答

Walter Roberson
Walter Roberson 2013-4-6
stats::covariance is a MuPAD routine that cannot be called directly from MATLAB. Use
feval(symengine, 'stats::covariance', [1, 2, 6, 9], [6, 9, 3, 7], Population)
  2 个评论
curoi
curoi 2013-9-9
When I do this, I get
Undefined function or variable 'Population'
Walter Roberson
Walter Roberson 2013-9-9
Ah, it is a keyword for that MuPAD call, not a variable you are passing in.
Try these two variations:
feval(symengine, 'stats::covariance', [1, 2, 6, 9], [6, 9, 3, 7], 'Population')
feval(symengine, 'stats::covariance', [1, 2, 6, 9], [6, 9, 3, 7], sym('Population'))

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MuPAD 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by