Realization of code function of calculating weights by using the analytic hierarchy process of matlab

Source: Internet
Author: User
function Q=AHP (A)
[M,n]=size (A);
Ri=[0 0 0.58 0.90 1.12 1.24 1.32 1.41 1.45 1.49 1.51];
R=rank (A); The rank of the Judgment matrix
[V,d]=eig (A); % to determine the eigenvalues and eigenvectors of the Matrix, v eigenvalues, D eigenvectors;
Tz=max (D);
B=max (TZ); % Maximum characteristic value
[Row, Col]=find (d==b); % Maximum Eigenvalue location
C=v (:, col); % corresponding feature vector
Ci= (b-n)/(n-1); % Calculation Consistency Test indicator CI
Cr=ci/ri (1,n);
If cr<0.10
Disp (' ci= ');d ISP (CI);
Disp (' cr= ');d ISP (CR);
Disp (' contrast matrix A through consistency test, each vector weight vector q is: ');
Q=zeros (n,1);
For I=1:n
Q (i,1) =c (i,1)/sum (C (:, 1)); % feature vector normalization
End
Else
Disp (' Contrast matrix A does not pass the conformance test, need to reconstruct ' the contrast matrix A ');

End


The above is written in M file, finally add a judgment matrix in the main interface, call the function method: AHP (A);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.