% ltehdlCellSearch model analysis script
% Post-processes model outputs and generates plots.

% Check if any simulation output exists to analyze.
if exist('out','var') && ~isempty(out.PSSDetected)
    
    % Post-process the model output to extract key cell parameters,
    % diganostics and signals.
    
    [signals, report] = ltehdlCellSearchTools.processOutput(dataIn,startIn,out);
    
    % Plot results
    
    ltehdlCellSearchTools.figure('Input waveform and search stages'); clf;
    ltehdlCellSearchTools.plotSearchStates(signals,report);
    
    ltehdlCellSearchTools.figure('Frequency estimation'); clf;
    ltehdlCellSearchTools.plotFrequencyEstimate(signals,report);
    
    ltehdlCellSearchTools.figure('PSS search'); clf;
    ltehdlCellSearchTools.plotPSSCorrelation(signals,report);
    
    ltehdlCellSearchTools.figure('SSS search');
    ltehdlCellSearchTools.plotSSSCorrelation(signals,report);

end
