0001 function TorF = isobservable(H, pv, pq)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 tol = 1e-5;
0018 check_reason = 1;
0019
0020
0021
0022
0023 [m, n] = size(H);
0024 r = rank(H);
0025 if r < min(m, n)
0026 TorF = 0;
0027 else
0028 TorF = 1;
0029 end
0030
0031
0032 if check_reason && ~TorF
0033
0034 idx_trivialColumns = [];
0035 varNames = {};
0036 for j = 1:n
0037 normJ = norm(H(:, j), inf);
0038 if normJ < tol
0039 idx_trivialColumns = [idx_trivialColumns j];
0040 varName = getVarName(j, pv, pq);
0041 varNames{length(idx_trivialColumns)} = varName;
0042 end
0043 end
0044
0045 if ~isempty(idx_trivialColumns)
0046 fprintf('Warning: The following variables are not observable since they are not related with any measurement!');
0047 varNames
0048 idx_trivialColumns
0049 else
0050
0051 for j = 1:n
0052 rr = rank(H(:, 1:j));
0053 if rr ~= j
0054
0055 colJ = H(:, j);
0056 varJName = getVarName(j, pv, pq);
0057 for k = 1:j-1
0058 colK = H(:, k);
0059 if rank([colK colJ]) < 2
0060 varKName = getVarName(k, pv, pq);
0061 fprintf('Warning: %d(th) column vector (w.r.t. %s) of H is linearly dependent of %d(th) column vector (w.r.t. %s)!\n', j, varJName, k, varKName);
0062 return;
0063 end
0064 end
0065 end
0066 end
0067 fprintf('Warning: No specific reason was found for system being not observable.\n');
0068 end
0069 end