Engee documentation

modulate

Modulation for modeling communication systems.

Library

EngeeDSP

Syntax

Function call

  • (y, t) = modulate(x, fc, fs, method, opt) — modulates a real useful signal x using a carrier frequency fc, sampling rates fs and the method method with additional parameters specified in opt and returns the internal time vector t.

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

  • (y, t) = modulate(x, fc, fs) — modulates a real useful signal x using a carrier frequency fc and sampling rates fs. If x If the modulated signal is a matrix, then the modulated signal is calculated independently for each column and stored in the corresponding column. y.

Arguments

Input arguments

# x is a useful signal

+ vector | the matrix

Details

A useful signal defined as a real vector or matrix.

# 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" (by default) | "amdsb-sc" | "amdsb-tc" | "amssb" | "fm" | "pm" | "pwm" | "ppm" | "qam"

Details

The modulation method used, possible values:

  • "am" or "amdsb-sc" — amplitude modulation, two side bands, suppressed carrier. Multiplies x to a sinusoid with a frequency fc.

    y = x.*cos(2*pi*fc*t)
  • "amdsb-tc" — amplitude modulation, two side bands, transmitted carrier. Subtracts a scalar value opt from x and multiplies the result by a sinusoid with a frequency fc.

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

    If you do not specify opt Then modulate uses the default value min(min(x)) to provide a useful signal (x-opt) it was non-negative and had a minimum value of 0.

  • "amssb" — amplitude modulation, single sideband. Multiplies x on a sinusoid with a frequency fc and adds the result to the Hilbert transform. x multiplied by a phase - shifted sinusoid with frequency fc.

    y = x.*cos(2*pi*fc*t)+imag(hilbert(x)).*sin(2*pi*fc*t)

    This method effectively eliminates the upper sideband.

  • "fm" — frequency modulation. Creates a sinusoid with an instantaneous frequency that varies depending on the desired signal. x.

    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 modulation. Creates a sinusoid with a frequency of fc, the phase of which varies depending on the useful signal x.

    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 modulation. Creates a modulated pulse width signal based on the pulse lengths in x. Elements x are in the range from 0 before 1 and determine the duration of each pulse in fractions of a period. The pulses start at the beginning of each carrier period, meaning they are aligned to the left. When calling the function modulate(x,fc,fs,"pwm","centered") the pulses are centered at the beginning of each period. Length _(y,t) equal to length(x)*fs/fc.

  • "ppm" — pulse-position modulation. Creates a pulse-position modulated signal from pulse positions in x. Elements x are in the range from 0 before 1 by setting the left edge of each pulse in fractions of a period. Meaning opt represents a scalar from 0 before 1, which determines the length of each pulse in fractions of a period. The default value for opt is 0.1. Length _(y,t) equal to length(x)*fs/fc.

  • "qam" — quadrature amplitude modulation. Creates a signal using quadrature amplitude modulation from the signals x and opt.

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

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

# opt — additional parameters for some methods

+ Custom type

Details

Additional parameters for some methods. Learn more in method.

Data types

Float32, Float64, Char, String

Support for complex numbers

Yes

Output arguments

# y — modulated useful signal

+ vector | the matrix

Details

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

# t is the internal time vector

+ vector

Details

The internal time vector.