%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [d,r1]=floyd1(vx,vy)
b=inf
a=[0 2 8 1 b b b b
2 0 6 b 1 b b b
8 6 0 7 5 1 2 b
1 b 7 0 b b 9 b
b 1 5 b 0 3 b 8
b b 1 b 3 0 4 6
b b 2 9 b 4 0 3
b b b b 8 6 3 0 ]
d=a
vx=vx+1
vy=vy+1
global r
r=a
for i=1:8
for j=1:8
d(i,j)=a(i,j)
r(i,j)=j
k=1
end
end
for k=1:8
for i=1:8
for j=1:8
if d(i,k)+d(k,j)<d(i,j)
d(i,j)=d(i,k)+d(k,j)
r(i,j)=k
end
end
end
end
r1=r-1
fun3(vx,vy)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
在Matlab下输入:edit,然后将下面两行百分号告团之间的内容,复制进去,保存
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function fun3(vx,vy)
global r
t=r(vx,vy)
if vy==t
return
else
fun3(vx,t)
disp(t-1)
fun3(t,vy)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
返回matlab 输入:
[d,r1]=floyd1(1,3) %这袜毁橘里我也不知道什么意思。但是能运行就是了。
%层次分析法的matlab程序
1、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.0001i=2k=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))
disp('权向量')disp(w)
disp('最大特征值')disp(t)
2、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('权向量')disp(w)
disp('最大特征值')disp(t)
%以下是一致性检验
扩展资料:
Matlab是一个高级的矩阵/阵列语言,它包含控制语句、函数、数据结构、输入和输出和面向对象编程特点。用户可以在命令窗口中将输入语句与执行命令同步,也可以先编写好一个较大的复杂的应用程序(M文件)后再一起运行。
新版本的MATLAB语言瞎带是基于最为流行的C++语言基础上的,因此语法特征与C++语言极为相似,而且更加简单,更加符合科薯孙技人员对数学表达式的书写格式。使之更利于非计算机专业的科技人员使用。而且这种语言可移植性好、可拓展性极强,这也是MATLAB能够深入到科学研究数神链及工程计算各个领域的重要原因。
参考资料来源:百度百科-MATLAB
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)