解释下各个程序的段的意思!哪个大侠帮我下,很感谢

解释下各个程序的段的意思!哪个大侠帮我下,很感谢
%file maxnorm.mfunction t=maxnorm(a) %the maximum element of the arrayn=length(a); t=0; for i=1:n if abs(a(i)/max(abs(a)))>=1 t=a(i); end end%%%%把上面的文件存为maxnorm.m%file maxtr.mfunction [mt,my]=maxtr(a,eps)%a the matrix%eps the accept error ,you decide it%mt the maximum eigenvalue of the matrix%my the corresponding eigenvector of mtn=length(a); x0=diag(ones(n)); k=1; x=a*x0; while norm(x-x0)>eps k=k+1; q=x; y=x/maxnorm(x); x=a*y; x0=q; end mt=maxnorm(x);my=y;%%%%把上面的文件存为maxtr.m
折翅的心灵 1年前 已收到1个回答 举报

dnlpoqf2 春芽

共回答了11个问题采纳率:81.8% 举报

这个程序是扯淡,既然是要求最大元素,可是你使用了Matlab自带的max函数先求出最大值,再用每一个元素与最大比做商比较,这还有什么意义呢,不是胡扯吗%file maxnorm.mfunction t=maxnorm(a) %the maximum element of the arrayn=length(a); t=0; for i=1:n if abs(a(i)/max(abs(a)))>=1 t=a(i); end 这个函数用来求矩阵的特征值和特征向量的%file maxtr.mfunction [mt,my]=maxtr(a,eps)%a the matrix输入矩阵%eps the accept error ,you decide it误差容限%mt the maximum eigenvalue of the matrix特征值%my the corresponding eigenvector of mt特征向量n=length(a); %矩阵长度x0=diag(ones(n)); %对角线原始% 下面是算法具体不好说明,因为我不知道用的是那个算法% 由于使用的都是简单的复制,加减乘除语句,很好理解的k=1; x=a*x0; while norm(x-x0)>eps %判断是否达到误差容限 k=k+1; q=x; y=x/maxnorm(x); x=a*y; x0=q;endmt=maxnorm(x);%返回特征值my=y;%返回特征向量 查看原帖

1年前

9
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.012 s. - webmaster@yulucn.com