⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 suanfa.txt

📁 基于matlab灰色关联度计算的实现
💻 TXT
字号:
http://hi.baidu.com/shylockshi/blog/category/Matlab
http://blog.163.com/zhiyuan_2001/blog/#pn9
http://www.aideas.com/Calculator/ChineseScholars.htm


基于matlab灰色关联度计算的实现2006年07月28日 星期五 上午 11:06
function r=incident_degree(x0,x1) 
%compute the incident degree for grey model. 

%Designed by NIXIUHUI,Dalian Fisher University. 
%17 August,2004,Last modified by NXH at 21 August,2004        

%数据初值化处理 
x0_initial=x0./x0(1); 
temp=size(x1); 
b=repmat(x1(:,1),[1 temp(2)]); 
x1_initial=x1./b; 

%分辨系数选择 
K=0.1; 

disp('The grey interconnect degree is: '); 


x0_ext=repmat(x0_initial,[temp(1) 1]); 
contrast_mat=abs(x0_ext-x1_initial); 

delta_min=min(min(contrast_mat));%delta_min在数据初值化后实际为零 
delta_max=max(max(contrast_mat)); 
a=delta_min+K*delta_max; 
incidence_coefficient=a./(contrast_mat+K*delta_max);%得到关联系数 

r=(sum(incidence_coefficient'))'/temp(2);      %得到邓氏面积关联度
 







基于matlab灰色预测GM(1,1)实现
function [y,p,e]=gm_1_1(X,k) 
%Build the calculating dieplate for the typical gray model. 
%Example [y,p]=gm_1_1([200 250 300 350],2) 
%Designed by NIXIUHUI,Dalian Fisher University. 
%20 April,2004. Last modified by NXH at 25 September,2004    

if nargout>3,error('Too many output argument.');end 
if nargin==1,k=1;x_orig=X; 
elseif nargin==0|nargin>2 
   error('Wrong number of input arguments.'); 
end 
x_orig=X; 
predict=k; 

%AGO process 
x=cumsum(x_orig); 


%compute the coefficient(a and u)------------------------ 
n=length(x_orig); 
%first generate the matrix B 
for i=1:(n-1); 
B(i)=-(x(i)+x(i+1))/2; 
end 
B=[B' ones(n-1,1)]; 
%then generate the matrix Y 
for i=1:(n-1); 
y(i)=x_orig(i+1); 
end 
Y=y'; 
%get the coefficient. a=au(1) u=au(2) 
au=(inv(B'*B))*(B'*Y); 
%-------------------------------------------------------- 
%change the grey model to symbolic expression 
coef1=au(2)/au(1); 
coef2=x_orig(1)-coef1; 
coef3=0-au(1); 
costr1=num2str(coef1); 
costr2=num2str(abs(coef2)); 
costr3=num2str(coef3); 
eq=strcat(costr1,'+',costr2,'e^',costr3,'*(t-1))'); 


%comparison of calculated and observed value 
for t=1:n+predict 
   mcv(t)=coef1+coef2*exp(coef3*(t-1)); 
end 
x_mcv0=diff(mcv); 
x_mcve=[x_orig(1) x_mcv0]; 
x_mcv=diff(mcv(1:end-predict)); 
x_orig_n=x_orig(2:end); 
x_c_error=x_orig_n-x_mcv; 
x_error=mean(abs(x_c_error./x_orig_n)); 

if x_error>0.2 
   disp('model disqualification!'); 
elseif x_error>0.1 
   disp('model check out'); 
else 
   disp('model is perfect!'); 
end 
%predicting model and plot gragh 
plot(1:n,x_orig,'diamond',1:n+predict,x_mcve); 
p=x_mcve(end-predict+1:end); 
xlabel('CURVE OF GREY MODEL ANALYSIS'); 
title('GM(1,1)'); 
grid on 
y=eq; 
e=x_error; 
p=x_mcve(end-predict+1:end);
 





基于matlab层次分析法的实现2006年07月28日 星期五 上午 11:04
disp('请输入判断矩阵A(n阶)');
A=input('A=');
[n,n]=size(A);
x=ones(n,100);
y=ones(n,100);
m=zeros(1,100);
m(1)=max(x(:,1));
y(:,1)=x(:,1);
x(:,2)=A*y(:,1);
m(2)=max(x(:,2));
y(:,2)=x(:,2)/m(2);
p=0.0001;i=2;k=abs(m(2)-m(1));
while  k>p
  i=i+1;
  x(:,i)=A*y(:,i-1);
  m(i)=max(x(:,i));
  y(:,i)=x(:,i)/m(i);
  k=abs(m(i)-m(i-1));
end
a=sum(y(:,i));
w=y(:,i)/a;
t=m(i);
disp(w);disp(t);
         %以下是一致性检验
CI=(t-n)/(n-1);RI=[0 0 0.52 0.89 1.12 1.26 1.36 1.41 1.46 1.49 1.52 1.54 1.56 1.58 1.59];
CR=CI/RI(n);
if CR<0.10
    disp('此矩阵的一致性可以接受!');
    disp('CI=');disp(CI);
    disp('CR=');disp(CR);
end
 


(转)基于matlab冒泡法排序的实现2006年07月28日 星期五 上午 11:04function y=bubblesort(x) 
%冒泡法排序. 
%Designed by NIXIUHUI,Dalian Fisher University.   

r=length(x); 
for i=1:r-1 
   for j=i+1:r 
       if x(i)>x(j) 
           temp=x(i); 
           x(i)=x(j); 
           x(j)=temp; 
       end 
   end 
end 
y=x; 




⌨️ 快捷键说明

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