📄 range.m
字号:
function Q = range(A)% RANGE -- find range of a matrix%% Q = range(A)%% This does essentially the same thing as the Matlab system% routine ORTH, except it uses the tolerance parameter MPOLY_TOLERANCE% instead of the Matlab default tolerance.%% Also, this routine will accept symbolic matrices, so checking for that% is not required in other places. Symbolic matrices are converted to % DOUBLE, since there is no symbolic version of ORTH.% Copyright (c) 2004 by Fritz Keinert (keinert@iastate.edu),% Dept. of Mathematics, Iowa State University, Ames, IA 50011.% This software may be freely used and distributed for non-commercial% purposes, provided this copyright statement is preserved, and% appropriate credit for its use is given.%% Last update: Feb 20, 2004global MPOLY_TOLERANCEif isempty(MPOLY_TOLERANCE) tol = 1.e-12;else tol = MPOLY_TOLERANCE;end[m,n] = size(A);if (isnumeric(A))% this is essentially the built-in routine ORTH, except with different tolerance [U,S,V] = svd(A,0); if m > 1 s = diag(S); elseif m == 1 s = S(1); else s = 0; end r = sum(s > tol); Q = U(:,1:r); returnend% if we get to this point, A is symbolicif (issymbolic(A))% matrix contains symbolic variables error('range is not defined for matrices containing symbolic variables');end% If we get here, the matrix contains symbolic constants% We do a Gram-Schmid orthonormalization (without pivoting, % since the values are exact).% Zero vectors get tossed out.Q = sym(zeros(m,0));for i = 1:n u = A(:,i); for j = 1:size(Q,2) u = u - (u'*Q(:,j))*Q(:,j); end if iszero(u) continue end u = u / norm(u); Q = [Q,u];end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -