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