📄 issingular.m
字号:
function yesno = issingular(S)% ISSINGULAR -- checks whether a symbolic matrix is singular%% yesno = issingular(S)%% We test for singularity by testing whether the determinant % is zero or not.%% If S contains only symbolic constants (not symbolic variables), % we do this numerically (within tolerance).%% If S contains symbolic variables, we do it symbolically.% If this routine reports that such an S is singular, that will be correct.% However, if Matlab is not able to simplify the determinant sufficiently, % A singular S may be incorrectly reported as nonsingular.% 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, 2004% check that S is square and two-dimensional[n1,n2,n3] = size(S);if (n1 ~= n2 | n3 > 1) yesno = 1; returnend% try to simplify firstn = size(S);S = reshape(simplify(S(:)),n);try S = double(S); yesno = iszero(det(S));catch% if S contains symbolic variables without numerical values,% the conversion to "double" will fail. Then we end up here.% We do the same thing, except this time the determinant% is symbolic yesno = iszero(simplify(det(S)));end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -