matlab怎么求相关系数
有时候我们在使用matlab的时候,想求相关系数,怎么求呢,下面来分享一下方法第一步我们首先需要知道matlab中求相关系数用到的是corrcoef函数,在命令行窗口中输入“helpcorrcoef”,可以看到corrcoef函数用法,:
第二步在命令行窗口中输入a=[1367816],b=[24791519],创建两个矩阵,求两个矩阵的相关系数,:
第三步输入corrcoef(a,b),按回车键,可以看到两个矩阵的相关系数是0.9454,呈高度相关,:
第四步输入corrcoef(a),可以求a矩阵的相关系数,如果a矩阵是个多维矩阵,可以通过corrcoef(a(:,1),a(:,2))求每一列的相关系数,:
第五步按回车键之后,可以a矩阵自身的相关系数为1,这里需要注意的是相关系数0.00-±0.3是微相关,±0.30-±0.50是实相关,±0.50-±0.80是显著相关,±0.80-±1.00是高度相关,:
绛旓細鐩稿叧绯绘暟灏辩敤鍛戒护corrcoef min(min(corrcoef(x1, x2))) 灏辨槸x1,x2涔嬮棿鐨勭浉鍏崇郴鏁般傛瘮濡 t = (1:0.1:100)';w = 2*pi;x1=sin(w*t)+randn(size(t));x2=cos(w*t)+randn(size(t));x3=sin(w*t)+randn(size(t));x1_x2 = min(min(corrcoef(x1, x2)))x1_x3 = min(min(...
绛旓細绠鍗曠殑璇村氨鏄敤corrcoef鍑芥暟鏉ヨ绠椼傝繖鏄姹傜浉鍏搴︾殑缁撴灉锛屽浜庝竴鑸殑鐭╅樀X锛屾墽琛孉=corrcoef(X)鍚庯紝A涓瘡涓肩殑鎵鍦ㄨa鍜屽垪b锛屽弽搴旂殑鏄師鐭╅樀X涓浉搴旂殑绗琣涓垪鍚戦噺鍜岀b涓垪鍚戦噺鐨勭浉浼肩▼搴︼紙鍗鐩稿叧绯绘暟锛夈傝绠楀叕寮忔槸锛欳(1,2)/SQRT(C(1,1)*C(2,2))锛屽叾涓瑿琛ㄧず鐭╅樀[f,g]鐨勫崗鏂瑰樊鐭╅樀锛...
绛旓細1銆鐩稿叧绯绘暟灏辩敤鍛戒护corrcoef min(min(corrcoef(x1, x2))) 灏辨槸x1,x2涔嬮棿鐨勭浉鍏崇郴鏁般傛瘮濡 t = (1:0.1:100)';w = 2*pi;x1=sin(w*t)+randn(size(t));x2=cos(w*t)+randn(size(t));x3=sin(w*t)+randn(size(t));x1_x2 = min(min(corrcoef(x1, x2)))x1_x3 = min(...
绛旓細1銆鐩稿叧绯绘暟灏辩敤鍛戒护corrcoef min(min(corrcoef(x1, x2))) 灏辨槸x1,x2涔嬮棿鐨勭浉鍏崇郴鏁般傛瘮濡 t = (1:0.1:100)';w = 2*pi;x1=sin(w*t)+randn(size(t));x2=cos(w*t)+randn(size(t));x3=sin(w*t)+randn(size(t));x1_x2 = min(min(corrcoef(x1, x2)))x1_x3 = min(...
绛旓細浣跨敤鍑芥暟corrcoef鍗冲彲姹傚嚭锛屼笅闈㈡槸涓涓緥瀛愶細helpcorrcoefx=randn(30,4);%Uncorrelateddatax(:,4)=sum(x,2);%Introducecorrelation.[r,p]=corrcoef(x)%Computesamplecorrelationandp-values.[i,j]=find(p
绛旓細浣跨敤鏈灏忎簩涔樻硶姹傜郴鏁a,b,c 鍗充娇鐢╬olyfit鍑芥暟 P = POLYFIT(X,Y,N) 锛孨=2銆 寰楀埌鐨勭粨鏋淧鏄釜鍚戦噺锛屽垎鍒瓨鏀綼,b,c 姹傜浉鍏崇郴鏁鐢╟orrcoef(y1,y2)
绛旓細1.Matlab涓粈涔堟槸浜掔浉鍏冲嚱鏁matlab涓簰鐩稿叧鍑芥暟鏄痻corr(x,y). x鍜寉鏄緭鍏ヤ俊鍙枫備簰鐩稿叧鍑芥暟鍊奸粯璁ょ殑浜掔浉鍏宠绠楀叕寮忓涓嬶細锛堝彲浠ョ湅鍑猴紝瀵瑰疄淇″彿鏉ヨ锛屼簰鐩稿叧鍑芥暟鍊肩粨鏋滄槸瀵圭О鐨勶級2. Matlab涓粈涔堟槸浜鐩稿叧绯绘暟浜掔浉鍏崇郴鏁版槸鎸囧綊涓鍖栫殑浜掔浉鍏冲嚱鏁板笺傜敤娉曚负锛歺corr(x,y,'coeff');%'coeff'涓哄綊涓鍖栭夐」...
绛旓細1銆鐩稿叧绯绘暟灏辩敤鍛戒护corrcoefmin(min(corrcoef(x1,x2)))灏辨槸x1,x2涔嬮棿鐨勭浉鍏崇郴鏁般傛瘮濡倀=(1:0.1:100)';w=2*pi;x1=sin(w*t)+randn(size(t));x2=cos(w*t)+randn(size(t));x3=sin(w*t)+randn(size(t));x1_x2=min(min(corrcoef(x1,x2)))x1_x3=min(min(corrcoef(x1,x3)...
绛旓細涓诲嚱鏁癱lc;clear alla=[1,2,3,4;2,4,5,6;23,34,2,0];b=[2;3;5];%a鏄4鍒3琛岋紱b鏄1鍒3琛孾M,N]=size(a);corr=zeros(1,N);for i=1:Ncorr(i)=min(min(corrcoef(a(:,i),b)));enddisp(corr)%鏄剧ず鎵姹傜浉鍏崇郴鏁缁撴灉锛0.9573 0.9617 -0.5000 -0.7857>>甯屾湜...
绛旓細x=[銆傘傘俔y=[.銆傘傘俔y1=fun(a,x); %璋冪敤宸茬煡鎷熷悎鍑芥暟锛屾眰鍑簓1鍊 s1=(y-y1).^2;S1=sum(s1)y_ave=mean(y);s2=(y-y_ave).^2;S2=sum(s2)RR2=1-S1/S2