www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@localresponse/DiagnosticStatistics.m
function S = DiagnosticStatistics(R,TestNumbers,Stats) %DIAGNOSTICSTATISTICS Calculate local diagnostic statistics for specified tests. % % S = DIAGNOSTICSTATISTICS( LOCALRESPONSE, TESTNUMBERS ) % S = DIAGNOSTICSTATISTICS( LOCALRESPONSE, TESTNUMBERS, STATS ) % S = DIAGNOSTICSTATISTICS( LOCALRESPONSE ) % Copyright 2004-2015 The MathWorks, Inc. if nargin<2 || (ischar(TestNumbers) && strcmp(TestNumbers, ':')) TestNumbers= 1:R.NumberOfTests; elseif islogical(TestNumbers) TestNumbers = find(TestNumbers); end if ~isnumeric(TestNumbers) || any(TestNumbers<1) || any(TestNumbers>R.NumberOfTests) || ... any(TestNumbers~=fix(TestNumbers)) error(message('mbc:mbcmodel:localresponse:InvalidValue')) end % call diagnosticStats for first [~,~,DataOK]= FitData(R.Object, TestNumbers(1) ); [stats, Names]= diagnosticStats(R.Object, TestNumbers(1)); data = zeros(length(DataOK),length(Names)); data(DataOK,:)= stats; % removed data data(~DataOK,:)= NaN; for i=2:length(TestNumbers) % call diagnosticStats for each test [~,~,DataOK]= FitData(R.Object, TestNumbers(i) ); [s , iNames]= diagnosticStats(R.Object, TestNumbers(i)); if ~isequal(iNames,Names) error(message('mbc:mbcmodel:localresponse:InvalidProperty', TestNumbers( i ))) end D = zeros(length(DataOK),length(Names)); D(DataOK,:)= s; % removed data D(~DataOK,:)= NaN; % augment tests data = [data ; D]; %#ok<AGROW> end if nargin > 2 % select some of the statistics if ischar(Stats) Stats = {Stats}; end ism = false(1,length(Stats)); StatsIndices = zeros(1,length(Stats)); for i=1:length(Stats) ind = find(strncmpi(Stats{i},Names,length(Stats{i}))); ism(i) = isscalar(ind); if ism(i) StatsIndices(i) = ind; end end if ~all(ism) error(message('mbc:mbcmodel:response:InvalidProperty')); end % only return data S= data(:,StatsIndices); else % structure S.Statistics = data; S.Names= Names; end