function [SpectrumAnalyzer,TimeScope,ConstellationDiagram] = ...
    vhtSigRecSetupPlots(sr)
%vhtSigRecSetupPlots Featured example helper function
%
%   Creates and configures analysis objects

%   Copyright 2015-2017 The MathWorks, Inc.

% Scale and position plots on the screen
[repositionPlots,position] = helperPlotPositions();

% Create spectrum analyzer to plot spectrum of packet
SpectrumAnalyzer = dsp.SpectrumAnalyzer;
SpectrumAnalyzer.Name = 'Detected packet signal spectrum';
SpectrumAnalyzer.SampleRate = sr;
SpectrumAnalyzer.ShowLegend = true;
SpectrumAnalyzer.RBWSource = 'Property';
SpectrumAnalyzer.RBW = 100e3;
SpectrumAnalyzer.SpectralAverages = 3;
if repositionPlots
    SpectrumAnalyzer.Position = position(1,:);
end

% Create time scope to plot detected packet
TimeScope = timescope;
TimeScope.Name = 'Detected packet';
TimeScope.YLabel = 'Magnitude';
TimeScope.PlotType = 'Line';
TimeScope.ShowGrid = true;
TimeScope.ShowLegend = true;
TimeScope.SampleRate = sr;
TimeScope.TimeSpanSource = 'Property';
if repositionPlots
    TimeScope.Position = position(2,:);
end

% Create a constellation diagram for each potential spatial stream
NssMax = 8; % Maximum number of spatial streams
ConstellationDiagram = cell(NssMax,1);
for iss = 1:NssMax
    ConstellationDiagram{iss} = comm.ConstellationDiagram;
    ConstellationDiagram{iss}.ShowReferenceConstellation = true;
    ConstellationDiagram{iss}.ShowGrid = true;
    ConstellationDiagram{iss}.Name = 'Equalized data symbols';
    ConstellationDiagram{iss}.Title = ['Spatial stream ' num2str(iss)];
    if (repositionPlots)
        if mod(iss,2)
            ConstellationDiagram{iss}.Position = position(3,:);
        else
            ConstellationDiagram{iss}.Position = position(4,:);
        end
    end
end

end