Filter löschen
Filter löschen

Unexpected matlab operator Covariance

2 Ansichten (letzte 30 Tage)
curoi
curoi am 6 Apr. 2013
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?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Apr. 2013
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 Kommentare
curoi
curoi am 9 Sep. 2013
When I do this, I get
Undefined function or variable 'Population'
Walter Roberson
Walter Roberson am 9 Sep. 2013
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'))

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MuPAD finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by