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

📄 gausjord.mht

📁 it is a very essential matlab code.
💻 MHT
字号:
From: <Saved by Windows Internet Explorer 7>
Subject: 
Date: Tue, 12 May 2009 09:49:44 -0700
MIME-Version: 1.0
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: 7bit
Content-Location: http://www.mece.ualberta.ca/Courses/mec390/390code/gausjord.m
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.6000.16825" name=GENERATOR></HEAD>
<BODY><PRE>function [x, err] = gausjord(A, b)
% Gauss - Jordan Routine for solution of single system
%
% USAGE:   [x, err] = gauselim(A, b)
%  where   A = square coefficient matrix, size n X n
%          b = single RHS column vector, size n X 1
%          x = solution column vector, size n X 1
%        err = error code:
%                = 0 = no error
%                = 1 = singular matrix detected
%                = 2 = not a square matrix

err = 0;

%set up space for solution vector
x = zeros(size(b));

% check that input is legal
[n,m] = size(A);
if n ~= m
  disp('Error in gauselim: Matrix must be square.')
  err = 2; return
end

% form augmented matrix by adding b to last column of A
m = n+1; A(:,m) = b;

% ELIMINATION

for k = 1:n

  if k &lt; n
     [A, err] = gepivot(A, k);   % partial pivoting
  end

  if err ~= 0
     disp('Matrix is singular'); return
  end

  for i = 1:n
    if i ~= k
       term = A(i,k)/A(k,k);
       for j = k:m
          A(i,j) = A(i,j) - term*A(k,j);
       end
    end
  end

  % normalize
  temp = A(k,k)
  for j = k:m
    A(k,j) = A(k,j)/temp;
  end

end

x = A(:,m);


</PRE></BODY></HTML>

⌨️ 快捷键说明

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