# mskdemod

Minimum shift keying demodulation

## Syntax

```z = mskdemod(y,nsamp) z = mskdemod(y,nsamp,dataenc) z = mskdemod(y,nsamp,dataenc,ini_phase) z = mskdemod(y,nsamp,dataenc,ini_phase,ini_state) [z,phaseout] = mskdemod(...) [z,phaseout,stateout] = mskdemod(...) ```

## Description

`z = mskdemod(y,nsamp)` demodulates the complex envelope `y` of a signal using the differentially encoded minimum shift keying (MSK) method. `nsamp` denotes the number of samples per symbol and must be a positive integer. The initial phase of the demodulator is 0. If `y` is a matrix with multiple rows and columns, the function treats the columns as independent channels and processes them independently.

`z = mskdemod(y,nsamp,dataenc)` specifies the method of encoding data for MSK. `dataenc` can be either `'diff'` for differentially encoded MSK or `'nondiff'` for nondifferentially encoded MSK.

`z = mskdemod(y,nsamp,dataenc,ini_phase)` specifies the initial phase of the demodulator. `ini_phase` is a row vector whose length is the number of channels in `y` and whose values are integer multiples of `pi/2`. To avoid overriding the default value of `dataenc`, set `dataenc` to `[]`.

`z = mskdemod(y,nsamp,dataenc,ini_phase,ini_state)` specifies the initial state of the demodulator. `ini_state` contains the last half symbol of the previously received signal. `ini_state` is an `nsamp`-by-C matrix, where C is the number of channels in `y`.

`[z,phaseout] = mskdemod(...)` returns the final phase of `y`, which is important for demodulating a future signal. The output `phaseout` has the same dimensions as the `ini_phase` input, and assumes the values `0`, `pi/2`, `pi`, and `3*pi/2`.

`[z,phaseout,stateout] = mskdemod(...)` returns the final `nsamp` values of `y`, which is useful for demodulating the first symbol of a future signal. `stateout` has the same dimensions as the `ini_state` input.

## Examples

collapse all

Modulate and demodulate a noisy MSK signal. Display the number of received errors.

Define the number of samples per symbol for the MSK signal.

`nsamp = 16;`

Initialize the simulation parameters.

```numerrs = 0; modPhase = zeros(1,2); demodPhase = zeros(1,2); demodState = complex(zeros(nsamp,2));```

The main processing loop includes these steps:

• Generate binary data.

• MSK modulate the data.

• Pass the signal through an AWGN channel.

• Demodulate the MSK signal.

• Determine the number of bit errors.

```for iRuns = 1:20 txData = randi([0 1],100,2); [modSig,modPhase] = mskmod(txData,nsamp,[],modPhase); rxSig = awgn(modSig,20,'measured'); [rxData,demodPhase,demodState] = mskdemod(rxSig,nsamp,[],demodPhase,demodState); numerrs = numerrs + biterr(txData,rxData); end```

Display the number of bit errors.

`numerrs`
```numerrs = 0 ```

## References

[1] Pasupathy, S., "Minimum Shift Keying: A Spectrally Efficient Modulation". IEEE Communications Magazine, July, 1979, pp. 14–22.

## Version History

Introduced before R2006a