⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 a131.m

📁 matlab算法集 matlab算法集
💻 M
字号:
       %----------------------------------------------------------------
       % Example a1.3.1: Linear Algebraic Systems
       %----------------------------------------------------------------

       % Initialize

       clc                      % clear command window  
       clear                    % clear variables
       randinit(1000)           % select random sequence
       n = 5;                   % number of variables
       m = 250;                 % maximum iterations
       tol = 1.e-6;             % error tolerance
       alpha = 1.5;             % relaxation parameter 
       B = randu (n,n,-1,1);
       b = randu (n,1,-1,1);
       A = B'*B;

       % Solve system

       fprintf ('Example a1.3.1: Linear Algebraic Systems\n');
       show ('A',A)
       show ('b',b)
       show ('det(A)',det(A))
       show ('inv(A)',inv(A))
       show ('K(A)',condnum(A,0))
       x = gauss (A,b);
       show ('Gaussian elimination solution',x)
       show ('||r||',residual(A,b,x))
       x = zeros(n,1); 
       [x,k] = sr (x,A,b,alpha,tol,m);
       show ('Number of iterations',k);
       show ('Successive relaxation solution',x)
       show ('||r||',residual(A,b,x))
       %----------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -