%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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) %这袜毁橘里我也不知道什么意思。但是能运行就是了。
1、matlab是一个功能强大的软件,不仅仅在数据处理方面很优秀,在界面编程方面同样优秀,这里简单介绍下matlab界面编程的基础步骤。
2、在打开的matlab程序中,点击new---graphic user interface,打开创建gui向导--我们选择blank gui,创建空白的gui界面---选择左侧我们需要的控件,如下图,我们选择一个button---将控件拖入到gui界面的合适的位置,双击打开设置属性的界面---设计好界面后,我们先不要编写函数内容,先运行界面---他会提醒我们贺友激活界面将保存界面和代码,我们选择yes---输入文件名,点击保存---我们回到界面编辑界面,点击button右键打消绝开右键菜单,点拿拍姿击view callbacks---callback,来跳转到该控件的回调函数---我们在该函数中输入代码---这时,我们运行程序,点击按钮,即可以在命令窗口中看到button执行的效果。
3、先运行界面,使得matlab给我们创建界面的代码,然后在view callback。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)