解释下各个程序的段的意思!哪个大侠帮我下,很感谢
来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:数学作业 时间:2024/08/08 16:54:06
解释下各个程序的段的意思!哪个大侠帮我下,很感谢
%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
%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
![解释下各个程序的段的意思!哪个大侠帮我下,很感谢](/uploads/image/z/7820697-57-7.jpg?t=%E8%A7%A3%E9%87%8A%E4%B8%8B%E5%90%84%E4%B8%AA%E7%A8%8B%E5%BA%8F%E7%9A%84%E6%AE%B5%E7%9A%84%E6%84%8F%E6%80%9D%21%E5%93%AA%E4%B8%AA%E5%A4%A7%E4%BE%A0%E5%B8%AE%E6%88%91%E4%B8%8B%2C%E5%BE%88%E6%84%9F%E8%B0%A2)
这个程序是扯淡,既然是要求最大元素,可是你使用了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;%返回特征向量 查看原帖