correl.m

来自「英国剑桥出版社出版的bootstrap一书的附录程序」· M 代码 · 共 24 行

M
24
字号
function[Rxy]=correl(x,y)%%         function[Rxy]=correl(x,y)%         calculate the correlation coeficient%         of two vectors -input1 and input2 or %         gives the vector of correlation coeficients%         of the raws of matrix input1 and input2.%         Note, that input1 must have the%         same size as input2.[s1,s2]=size(x);if s1==1 | s2==1, x=x(:); y=y(:);end;mx1=mean(x);mx2=mean(x.^2);my1=mean(y);my2=mean(y.^2);Sxx=mx2-mx1.^2;Syy=my2-my1.^2;Sxy=mean(x.*y)-mx1.*my1;Rxy=Sxy./sqrt(Sxx.*Syy);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?