Engee documentation

demod

Demodulation for modeling communication systems.

Library

EngeeDSP

Syntax

Function call

  • x = demod(y, fc, fs, method, opt) — demodulates a real useful signal y using a carrier frequency fc, sampling rates fs and the method method with additional parameters specified in opt.

  • x = demod(y, fc, fs, method) — demodulates a real useful signal y using a carrier frequency fc, sampling rates fs and the method method.

Arguments

Input arguments

# y — modulated signal

+ vector | the matrix

Details

A modulated useful signal specified as a real vector or matrix. The signal y has the same dimension as x, except for the methods method: "pwm" and "ppm".

# fc — carrier frequency

+ scalar

Details

The carrier frequency used to modulate the useful signal is given as a real positive scalar.

# fs — sampling rate
scalar

Details

The sampling rate specified as a real positive scalar.

# method — modulating method

+ "am" (default) | "amdsb-sc" | "amdsb-tc" | "amssb" | "fm" | "pm" | "pwm" | "pmm" | "qam"

Details

The modulation method used, possible values:

  • "am" or "amdsb-sc" — amplitude demodulation, two side bands, suppressed carrier. Multiplies y on a sinusoid with a frequency of fc and applies a fifth-order Butterworth low-pass filter using the function filtfilt.

    x = y.*cos(2*pi*fc*t);
    [b,a] = butter(5,fc*2/fs);
    x = filtfilt(b,a,x);
  • "amdsb-tc" — amplitude demodulation, two side bands, transmitted carrier. Multiplies y on a sinusoid with a frequency fc and applies a fifth-order Butterworth low-pass filter using the function filtfilt.

    x = y.*cos(2*pi*fc*t);
    [b,a] = butter(5,fc*2/fs);
    x = filtfilt(b,a,x);

    If you specify opt Then demod subtracts the scalar value opt from x. The default value for the parameter opt equally 0.

  • "amssb" — amplitude demodulation. Multiplies y on a sinusoid with a frequency fc and applies a fifth-order Butterworth low-pass filter using the function filtfilt.

    x = y.*cos(2*pi*fc*t);
    [b,a] = butter(5,fc*2/fs);
    x = filtfilt(b,a,x);
  • "fm" — frequency demodulation. Demodulates the shape of a frequency-modulated (FM) signal by modulating the Hilbert transform y using a complex exponential frequency -fc Hz and gets an instantaneous frequency as a result.

    y=cos(2*pi*fc*t + opt*cumsum(x))

    Function cumsum is a rectangular approximation of the integral of x. Function modulate uses opt as a constant of frequency modulation. If you do not specify a value opt Then modulate uses the default value opt=(fc/fs)*2*pi/(max(max(x))), therefore , the maximum frequency deviation from fc will be fc Hz.

  • "pm" — phase demodulation. Demodulates the shape of a phase-modulated (FM) signal by modulating the Hilbert transform y using a complex exponential frequency -fc Hz and gets an instantaneous phase as a result.

    y=cos(2*pi*fc*t + opt*x)

    Function modulate uses opt as a constant of phase modulation. If you do not specify a value opt Then modulate uses the default value opt=pi/(max(max(x))), therefore , the maximum phase deviation will be glad.

  • "pwm" — pulse width demodulation. Defines the pulse width of a pulse-width modulated signal y. Function demod returns to x a vector whose elements determine the duration of each pulse in fractions of a period. Pulses in y They must start from the beginning of each carrier period, meaning they must be aligned to the left. When calling a function modulate(x,fc,fs,"pwm","centered") the pulses are centered at the beginning of each period. Length y equal to length(x)*fs/fc.

  • "ppm" — Positional pulse demodulation. Determines the pulse positions in a pulse-position modulated signal y. For proper demodulation, the pulses should not overlap. Length x equal to length(t)*fc/fs.

  • "qam" — quadrature amplitude demodulation. Function [x1,x2] = demod(y,fc,fs,"qam") multiplies y for cosine and sine with frequency fc and applies a fifth-order Butterworth low-pass filter using filtfilt.

    x1 = y.*cos(2*pi*fc*t);
    x2 = y.*sin(2*pi*fc*t);
    [b,a] = butter(5,fc*2/fs);
    x1 = filtfilt(b,a,x1);
    x2 = filtfilt(b,a,x2);

    Input argument opt must be of the same dimension as y.

# opt — additional parameters for some methods

+ Custom type

Details

Additional parameters for some methods. For more information, see method.

Data types

Float32, Float64, Char, String

Support for complex numbers

Yes

Output arguments

# x — demodulated useful signal

+ vector | the matrix

Details

A demodulated useful signal returned as a real vector or matrix.