0
|
1 ## Copyright (C) 2000 Kai Habel |
|
2 ## |
|
3 ## This program is free software; you can redistribute it and/or modify |
|
4 ## it under the terms of the GNU General Public License as published by |
|
5 ## the Free Software Foundation; either version 2 of the License, or |
|
6 ## (at your option) any later version. |
|
7 ## |
|
8 ## This program is distributed in the hope that it will be useful, |
|
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 ## GNU General Public License for more details. |
|
12 ## |
|
13 ## You should have received a copy of the GNU General Public License |
|
14 ## along with this program; if not, write to the Free Software |
|
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
16 |
|
17 ## -*- texinfo -*- |
|
18 ## @deftypefn {Function File} @var{r}= corr2 (@var{I},@var{J}) |
|
19 ## returns the correlation coefficient between @var{I} and @var{j}. |
|
20 ## @var{I,J} must be real type matrices or vectors of same size |
|
21 ## @end deftypefn |
|
22 |
|
23 |
|
24 ## Author: Kai Habel <kai.habel@gmx.de> |
|
25 ## Date: 01/08/2000 |
|
26 |
|
27 function r = corr2 (I, J) |
|
28 |
|
29 if !(nargin == 2) |
|
30 usage ("corr2(I,J)"); |
|
31 endif |
|
32 |
|
33 if !(is_matrix(I) && isreal(I) && is_matrix(J) && isreal(J)) |
|
34 error("argument must be a real type matrix"); |
|
35 endif |
|
36 |
|
37 if (size (I) != size (J)) |
|
38 error("arguments must be of same size") |
|
39 endif |
|
40 |
|
41 r = cov (I, J) / (std2(I)*std2(J)); |
|
42 endfunction |