早教吧作业答案频道 -->数学-->
求下面函数的解释,看不懂function A = fun(W)[m,n] = size(W); e = 0;for i = 1 :mfor j = i :nif W(i,j) = 0e = e + 1;E(e,:) = [i,j,W(i,j)];endendend% 按权值大小排列边的顺序for i = 1 :e - 1for j = i + 1 :eif E(i,3) > E(j,3)temp = E(j,
题目详情
求下面函数的解释,看不懂
function A = fun(W)
[m,n] = size(W);
e = 0;
for i = 1 :m
for j = i :n
if W(i,j) = 0
e = e + 1;
E(e,:) = [i,j,W(i,j)];
end
end
end
% 按权值大小排列边的顺序
for i = 1 :e - 1
for j = i + 1 :e
if E(i,3) > E(j,3)
temp = E(j,:);
E(j,:) = E(i,:);
E(i,:) = temp;
end
end
end
A = zeros(1,3);
S = 1 :n;
for i = 1 :e
% if find-set(u) = find-set(v)
if S(E(i,1)) = S(E(i,2))
% A = A + (u,v)
A = cat(1,A,E(i,:));
%union(u,v)
indicator = S(E(i,1));
for j = 1 :n
if S(j) == indicator
S(j) = S(E(i,2));
end
end
end
end
A(1,:) = [];
MATLAB求解求不出来。
function A = fun(W)
[m,n] = size(W);
e = 0;
for i = 1 :m
for j = i :n
if W(i,j) = 0
e = e + 1;
E(e,:) = [i,j,W(i,j)];
end
end
end
% 按权值大小排列边的顺序
for i = 1 :e - 1
for j = i + 1 :e
if E(i,3) > E(j,3)
temp = E(j,:);
E(j,:) = E(i,:);
E(i,:) = temp;
end
end
end
A = zeros(1,3);
S = 1 :n;
for i = 1 :e
% if find-set(u) = find-set(v)
if S(E(i,1)) = S(E(i,2))
% A = A + (u,v)
A = cat(1,A,E(i,:));
%union(u,v)
indicator = S(E(i,1));
for j = 1 :n
if S(j) == indicator
S(j) = S(E(i,2));
end
end
end
end
A(1,:) = [];
MATLAB求解求不出来。
▼优质解答
答案和解析
这是一个以算法、权值平均数为基础的复合函数,很多的赋值语句是计算机选修中VB的专用语句,解答出来非常麻烦,所以推荐你看一下这两本书(高一数学必修3,第一章,算法初步)与(算法与程序设计,VB选修).这两本书都是高一学的.
希望对您有帮助
希望对您有帮助
看了 求下面函数的解释,看不懂fu...的网友还看了以下:
欧拉恒等式e^iπ+1=0e^iπ=-1两边平方e^2iπ=1,e^0=1,2iπ=0,这肿么可能 2020-05-13 …
已知字母组合成英语单词1、e e t t i n h r 2、e e r a t w h 3、o 2020-05-14 …
选择元音字母在单词中发音不同的一项.1;A:h(a)nd;B:f(a)ce;C:(a)pple.2 2020-06-17 …
求下面函数的解释,看不懂function A = fun(W)[m,n] = size(W); e 2020-06-27 …
二叉树先序序列为E,F,H,I,G,J,K中序序列为H,F,I,E,J,K,G,那么这棵树是怎么排 2020-07-10 …
一个9位数abcdefghi满足:1.a+b+...+h+i=cd2.a(b+d-c)=243.( 2020-07-19 …
复数的运算问题比如比如(-1)^(-i)的如何运算的?因为由欧拉定理e^(pi*i)=-1(-1) 2020-08-02 …
三元一次方程组a*x+b*y+c*z+d=0,e*x+f*y+g*z+h=0,i*x+j*y+k* 2020-08-03 …
(-1)^(-i)=多少?(-1)^(-i)=[(-1)^(-1)]^i=(-1)^i=[e^(pi 2020-11-01 …
求证e^i(4π/n)+e^i(8π/n)+...+e^i4(n-1)π/n+e^i(4nπ/n)= 2020-11-01 …