Main Content

flushFilter

Flush transmit filter

    Description

    example

    out = flushFilter(obj) passes zeros through the transmit filter in the input waveform generator to flush the residual data samples that remain in the filter state. The function returns the residual data samples.

    You must call the input waveform generator System object (not only create the object) prior to using the flushFilter object function. The number of zeros passed through the transmit filter depends on the filter delay. This object function is required for the receiver simulations to recover all of the bits in the last physical layer frame.

    Examples

    collapse all

    Get information from a dvbs2WaveformGenerator System object by using the info function. Then retrieve the filter residual samples by using the flushFilter object function.

    This example uses MAT-files with LDPC parity matrices. If the MAT-files are not available on the path, download and unzip the MAT-files by entering this code at the MATLAB command prompt.

    if ~exist('dvbs2xLDPCParityMatrices.mat','file')
        if ~exist('s2xLDPCParityMatrices.zip', 'file')
            url = 'https://ssd.mathworks.com/supportfiles/spc/satcom/DVB/s2xLDPCParityMatrices.zip';
            websave('s2xLDPCParityMatrices.zip',url);
            unzip('s2xLDPCParityMatrices.zip');
        end
    addpath('s2xLDPCParityMatrices');
    end

    Specify the number of physical layer (PL) frames per stream.

    numFrames = 1;

    Create a Digital Video Broadcasting standard (DVB-S2) System object, and then specify its properties.

    s2WaveGen = dvbs2WaveformGenerator;
    s2WaveGen.NumInputStreams = 2;
    s2WaveGen.MODCOD = [21 16];
    s2WaveGen.DFL   = 47008;
    s2WaveGen.ISSYI = true;
    s2WaveGen.SamplesPerSymbol = 2;
    disp(s2WaveGen)
      dvbs2WaveformGenerator with properties:
    
               StreamFormat: "TS"
            NumInputStreams: 2
                   FECFrame: "normal"
                     MODCOD: [21 16]
                        DFL: 47008
              ScalingMethod: "outer radius as 1"
                  HasPilots: 0
              RolloffFactor: 0.3500
        FilterSpanInSymbols: 10
           SamplesPerSymbol: 2
                      ISSYI: true
                 ISCRFormat: "short"
    
      Show all properties
    

    Get the characteristic information about the DVB-S2 waveform generator.

    info(s2WaveGen)
    ans = struct with fields:
          ModulationScheme: {'16APSK'  '8PSK'}
        LDPCCodeIdentifier: {'5/6'  '8/9'}
    
    

    Create the bit vector of input information bits, data, of concatenated TS user packets.

    syncBits = [0 1 0 0 0 1 1 1]';       % Sync byte for TS packet is 47 Hex
    pktLen = 1496;                       % UP length without sync bits is 1496
    data =  cell(1,s2WaveGen.NumInputStreams);
    for i = 1:s2WaveGen.NumInputStreams
        numPkts = s2WaveGen.MinNumPackets(i)*numFrames;
        txRawPkts = randi([0 1],pktLen,numPkts);
        ISSY = randi([0 1],16,numPkts);   % ISCRFormat is 'short' by default
                                          % 'short' implies the default length of ISSY as 2 bytes
        txPkts = [repmat(syncBits,1,numPkts);txRawPkts;ISSY];    % ISSY is appended at the end of UP
        data{i} = txPkts(:);
    end

    Generate a DVB-S2 time-domain waveform using the information bits.

    txWaveform = [s2WaveGen(data)];

    Check the filter residual data samples that remain in the filter delay.

    flushFilter(s2WaveGen)
    ans = 20×1 complex
    
       0.0153 + 0.4565i
       0.2483 + 0.5535i
       0.3527 + 0.3972i
       0.3541 - 0.0855i
       0.3505 - 0.4071i
       0.4182 - 0.1962i
       0.5068 + 0.0636i
       0.4856 - 0.1532i
       0.3523 - 0.4153i
       0.1597 - 0.2263i
          ⋮
    
    

    Recover user packets (UPs) for multiple physical layer (PL) frames in a single transport stream Digital Video Broadcasting Satellite Second Generation (DVB-S2) transmission.

    This example uses MAT-files with LDPC parity matrices. If the MAT-files are not available on the path, download and unzip the MAT-files by entering this code at the MATLAB command prompt.

    if ~exist('dvbs2xLDPCParityMatrices.mat','file')
        if ~exist('s2xLDPCParityMatrices.zip','file')
            url = 'https://ssd.mathworks.com/supportfiles/spc/satcom/DVB/s2xLDPCParityMatrices.zip';
            websave('s2xLDPCParityMatrices.zip',url);
            unzip('s2xLDPCParityMatrices.zip');
        end
    addpath('s2xLDPCParityMatrices');
    end

    Specify the number of PL frames per stream. Create a DVB-S2 System object.

    nFrames = 2;
    s2WaveGen = dvbs2WaveformGenerator;

    Create the bit vector of information bits, data, of concatenated TS UPs.

    syncBits = [0 1 0 0 0 1 1 1]';    % Sync byte for TS packet is 47 Hex
    pktLen = 1496;                    % UP length without sync bits is 1496
    numPkts = s2WaveGen.MinNumPackets*nFrames;
    txRawPkts = randi([0 1],pktLen,numPkts);
    txPkts = [repmat(syncBits,1,numPkts); txRawPkts];
    data = txPkts(:);

    Generate the DVB-S2 time-domain waveform using the input information bits. Flush the transmit filter to handle the filter delay and recover the complete last frame.

    txWaveform = [s2WaveGen(data); flushFilter(s2WaveGen)];

    Add additive white Gaussian noise (AWGN) to the generated waveform.

    sps = s2WaveGen.SamplesPerSymbol; 
    EsNodB = 1;
    snrdB = EsNodB - 10*log10(sps);
    rxIn = awgn(txWaveform,snrdB,'measured');

    Create a raised cosine receiver filter.

    rxFilter = comm.RaisedCosineReceiveFilter( ...
          'RolloffFactor',s2WaveGen.RolloffFactor, ...
           'InputSamplesPerSymbol',sps,...
           'DecimationFactor',sps);
    s = coeffs(rxFilter);
    rxFilter.Gain = sum(s.Numerator);

    Apply matched filtering and remove the filter delay.

    filtOut = rxFilter(rxIn);
    rxFrame = filtOut(rxFilter.FilterSpanInSymbols+1:end);

    Recover UPs. Display the number of frames lost and the UP cyclic redundancy check (CRC) status.

    [bits,FramesLost,pktCRCStat] = dvbs2BitRecover(rxFrame,10^(-EsNodB/10));
    disp(FramesLost)
         0
    
    disp(pktCRCStat)
        {20×1 logical}
    

    Get information from a dvbs2xWaveformGenerator System object by using the info function. Then retrieve the filter residual samples by using the flushFilter object function.

    This example uses MAT-files with LDPC parity matrices. If the MAT-files are not available on the path, download and unzip the MAT-files by entering this code at the MATLAB command prompt.

    if ~exist('dvbs2xLDPCParityMatrices.mat','file')
        if ~exist('s2xLDPCParityMatrices.zip','file')
            url = 'https://ssd.mathworks.com/supportfiles/spc/satcom/DVB/s2xLDPCParityMatrices.zip';
            websave('s2xLDPCParityMatrices.zip',url);
            unzip('s2xLDPCParityMatrices.zip');
        end
    addpath('s2xLDPCParityMatrices');
    end

    Specify the number of physical layer (PL) frames per stream.

    numFrames = 2;

    Create a Digital Video Broadcasting Satellite Second Generation extended (DVB-S2X) System object and specify its properties. Use time slicing technique and variable coding and modulation configuration mode.

    s2xWaveGen = dvbs2xWaveformGenerator();
    s2xWaveGen.HasTimeSlicing = true;
    s2xWaveGen.NumInputStreams = 2;
    s2xWaveGen.PLSDecimalCode = [135 145];   % QPSK 9/20 and 8PSK 25/36
    s2xWaveGen.DFL = [18048 44656];
    s2xWaveGen.PLScramblingIndex = [0 1];
    disp(s2xWaveGen)
      dvbs2xWaveformGenerator with properties:
    
               StreamFormat: "TS"
             HasTimeSlicing: true
            NumInputStreams: 2
             PLSDecimalCode: [135 145]
                        DFL: [18048 44656]
          PLScramblingIndex: [0 1]
              RolloffFactor: 0.3500
        FilterSpanInSymbols: 10
           SamplesPerSymbol: 4
                      ISSYI: false
    
      Show all properties
    

    Get the characteristic information about the DVB-S2X waveform generator.

    info(s2xWaveGen)
    ans = struct with fields:
                  FECFrame: {'normal'  'normal'}
          ModulationScheme: {'QPSK'  '8PSK'}
        LDPCCodeIdentifier: {'9/20'  '25/36'}
    
    

    Create the bit vector of input information bits, data, of concatenated TS user packets for each input stream.

    syncBits = [0 1 0 0 0 1 1 1]';       % Sync byte for TS packet is 47 Hex
    pktLen = 1496;                       % UP length without sync bits is 1496
    data =  cell(1, s2xWaveGen.NumInputStreams);
    for i = 1:s2xWaveGen.NumInputStreams
        numPkts = s2xWaveGen.MinNumPackets(i)*numFrames;
        txRawPkts = randi([0 1], pktLen, numPkts);
        txPkts = [repmat(syncBits, 1, numPkts); txRawPkts];
        data{i} = txPkts(:);
    end

    Generate a DVB-S2X time-domain waveform using the information bits.

    txWaveform = s2xWaveGen(data);

    Check the filter residual data samples that remain in the filter delay.

    flushFilter(s2xWaveGen)
    ans = 40×1 complex
    
      -0.2412 - 0.0143i
      -0.2619 - 0.0861i
      -0.2726 - 0.1337i
      -0.2511 - 0.1597i
      -0.1851 - 0.1680i
      -0.0780 - 0.1602i
       0.0448 - 0.1288i
       0.1598 - 0.0751i
       0.2482 - 0.0049i
       0.3026 + 0.0702i
          ⋮
    
    

    Get information from a ccsdsTMWaveformGenerator System object by using the info function. Then retrieve the filter residual samples by using the flushFilter object function.

    Create a Consultative Committee for Space Data Systems (CCSDS) Telemetry (TM) System object. Set the waveform type as synchronization and channel coding with low-density parity-check (LDPC) channel coding. Display the properties.

    tmWaveGen = ccsdsTMWaveformGenerator;
    tmWaveGen.WaveformSource = "synchronization and channel coding";
    tmWaveGen.ChannelCoding = "LDPC";
    tmWaveGen.NumBitsInInformationBlock = 1024;
    tmWaveGen.Modulation = "QPSK";
    tmWaveGen.CodeRate = "1/2";
    disp(tmWaveGen)
      ccsdsTMWaveformGenerator with properties:
    
                   WaveformSource: "synchronization and channel coding"
                    HasRandomizer: true
                           HasASM: true
                        PCMFormat: "NRZ-L"
    
       Channel coding
                    ChannelCoding: "LDPC"
        NumBitsInInformationBlock: 1024
                         CodeRate: "1/2"
                     IsLDPCOnSMTF: false
    
       Digital modulation and filter
                       Modulation: "QPSK"
               PulseShapingFilter: "root raised cosine"
                    RolloffFactor: 0.3500
              FilterSpanInSymbols: 10
                 SamplesPerSymbol: 10
    
      Use get to show all properties
    

    Specify the number of transfer frames.

    numTF = 20;

    Get the characteristic information about the CCSDS TM waveform generator.

    info(tmWaveGen)
    ans = struct with fields:
             ActualCodeRate: 0.5000
           NumBitsPerSymbol: 2
        SubcarrierFrequency: []
    
    

    Generate the input bits for the CCSDS TM waveform generator, and then generate the waveform.

    bits = randi([0 1], tmWaveGen.NumInputBits*numTF,1);
    waveform = tmWaveGen(bits);

    Check the filter residual data samples that remain in the filter delay.

    flushFilter(tmWaveGen)
    ans = 100×1 complex
    
      -0.0772 - 0.0867i
      -0.0751 - 0.0859i
      -0.0673 - 0.0788i
      -0.0549 - 0.0654i
      -0.0388 - 0.0469i
      -0.0200 - 0.0250i
       0.0002 - 0.0012i
       0.0208 + 0.0227i
       0.0405 + 0.0453i
       0.0587 + 0.0653i
          ⋮
    
    

    Input Arguments

    collapse all

    Waveform generator object, specified as a dvbs2WaveformGenerator, dvbs2xWaveformGenerator, or ccsdsTMWaveformGenerator System object™.

    To enable the flushFilter object function when you specify obj as a ccsdsTMWaveformGenerator System object, you must set these dependencies in the ccsdsTMWaveformGenerator object.

    • Set the WaveformSource property to "synchronization and channel coding".

    • Set the ChannelCoding property to one of these values.

      • "none"

      • "RS"

      • "turbo"

      • "LDPC" — In this case, you must also set the IsLDPCOnSMTF property to 0 (false)

      • "convolutional" — In this case, you must also set the ConvolutionalCodeRate property to either "1/2" or "2/3"

      • "concatenated" — In this case, you must also set the ConvolutionalCodeRate property to either "1/2" or "2/3"

    • Set the Modulation property to either "BPSK" or "QPSK".

    Output Arguments

    collapse all

    Residual data samples that remain in the filter state, returned as a column vector. The length of the column vector is equal to the product of the SamplesPerSymbol and FilterSpanInSymbols properties of the input object, obj.

    When you specify obj as dvbs2WaveformGenerator or dvbs2xWaveformGenerator System object and the NumInputStream property as a value greater than 1, the data fields generated from different input streams are merged in a round-robin technique into a single stream. The residual samples of the frame after the merging process are flushed out.

    Data Types: double
    Complex Number Support: Yes

    Version History

    Introduced in R2021a