null.m
来自「it is a source code for geodesy」· M 代码 · 共 32 行
M
32 行
function N = null(A)
%NULL Nullspace of a matrix
% N = NULL(A) uses the pivoting LU factorization computed by
% PLU and the resulting reduced row echelon form computed by REF to
% find a matrix N whose columns are a basis for the nullspace of A.
% The number of columns of N is the nullity of A.
% If A has independent columns, then N is empty, N = [];
%
% (This supersedes the MATLAB function NULL(A) which computes a
% basis for the nullspace of A with orthonormal columns and, for
% badly conditioned problems, even a possibly different dimension.)
%
%See also PLU, REF, SOLVE.
[R,pivcol] = ref(A);
[m,n] = size(A);
% The rank is the number of pivot columns.
r = length(pivcol);
% The nonpivot columns of R provide a basis for the nullspace.
nopiv = 1:n;
nopiv(pivcol) = [];
N = zeros(n,n-r);
if n > r
N(nopiv,:) = eye(n-r,n-r);
if r > 0
N(pivcol,:) = -R(1:r,nopiv);
end
end
%%%%%%%%%%%%%%%%% end null.m %%%%%%%%%%%%%%%%%%%%%%
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?