I’m using the cov (covariance) function of Matlab and Octave. Actually I’m using Octave, but in the end it has to work for both. This function has an optional second or third parameters to indicate whether normalization should be done with N or N-1.
If I do this: cov(points,1) (where points is 4×2 matrix) I get following error:
error: cov: x and y must have the same number of observations
On a general note I would like to know how is Matlab/Octave able to distinguish if the second parameter is another matrix or an optional parameter (because it can have 2 or 3 parameters).
More specifically I would like to know how can I solve my problem?
Matlab cov() documentation: http://www.mathworks.de/help/techdoc/ref/cov.html
Octave cov() documentation: http://www.gnu.org/software/octave/doc/interpreter/Correlation-and-Regression-Analysis.html
EDIT: I’m using Octave 3.2.4 on Ubuntu 12.04
EDIT2: The solution is to install a newer version of Octave. This features was implemented after 3.2.
type
help cov, and note thatopthas been removeddoesn’t exist.better yet, do
and compare it to the
oldnew codeOpt is
gonerecent. Use Oli’s trick in the meantimeEdit: I take that back, this is a new feature. Not sure which version of Octave is using it, but you need an upgrade. Either, you do an unstable synaptic upgrade if you can find a repository, or you build it from source.
Edit 2: feature added Jan 2011 (3.4.1). 3.2.4 released Jan 2010. current version is 3.6.1