modulate
Modulation for communications simulation
Syntax
Description
Examples
Single-Sideband Amplitude Modulation
Generate a 10 Hz sinusoidal signal sampled at a rate of 200 Hz for 1 second. Embed the sinusoid in white Gaussian noise of variance 0.01.
fs = 200; t = 0:1/fs:1; x = sin(2*pi*10*t) + randn(size(t))/10;
Single-sideband amplitude modulate the signal with a carrier frequency of 50 Hz. Compute and display the new Welch's power spectral density estimates.
y = modulate(x,50,fs,'amssb'); pwelch([x;y]',hamming(100),80,1024,fs,'centered')
Quadrature Amplitude Modulation of Two Sinusoidal Signals
Generate two sinusoidal signals frequencies of 10 Hz and 20 Hz, sampled at a rate of 200 Hz for 1 second. Embed the sinusoids in white Gaussian noise of variance 0.01.
fs = 200; t = 0:1/fs:1; i = sin(2*pi*10*t) + randn(size(t))/10; q = sin(2*pi*20*t) + randn(size(t))/10;
Create a quadrature amplitude modulated signal from signals i
and q
using a carrier frequency of 70 Hz. Compute the Welch power spectral density estimates of the original and modulated sequences. Use a 100-sample Hamming window with 80 samples of overlap. Specify an FFT length of 1024.
y = modulate(i,70,fs,'qam',q); pwelch([i;q;y]',hamming(100),80,1024,fs,'centered') legend('In-phase signal','Quadrature signal','Modulated signal')
Input Arguments
x
— Message signal
real vector | real matrix
Message signal, specified as a real vector or matrix.
Example: sin(2*pi*25*[0:(1/200):1])
fc
— Carrier frequency
real positive scalar
Carrier frequency used to modulate the message signal, specified as a real positive scalar.
fs
— Sample rate
real positive scalar
Sample rate, specified as a real positive scalar.
method
— Method of modulation used
'am'
(default) | 'amdsb-sc'
| 'amdsb-tc'
| 'amssb'
| 'fm'
| 'pm'
| 'pwm'
| 'ppm'
| 'qam'
Method of modulation used, specified as one of these:
amdsb-sc
oram
— Amplitude modulation, double sideband, suppressed carrier. Multipliesx
by a sinusoid of frequencyfc
.y = x.*cos(2*pi*fc*t)
amdsb-tc
— Amplitude modulation, double sideband, transmitted carrier. Subtracts scalaropt
fromx
and multiplies the result by a sinusoid of frequencyfc
.y = (x-opt).*cos(2*pi*fc*t)
If you do not specify the
opt
parameter,modulate
uses a default ofmin(min(x))
so that the message signal(x-opt)
is entirely nonnegative and has a minimum value of 0.amssb
— Amplitude modulation, single sideband. Multipliesx
by a sinusoid of frequencyfc
and adds the result to the Hilbert transform ofx
multiplied by a phase-shifted sinusoid of frequencyfc
.y = x.*cos(2*pi*fc*t)+imag(hilbert(x)).*sin(2*pi*fc*t)
This effectively removes the upper sideband.
fm
— Frequency modulation. Creates a sinusoid with instantaneous frequency that varies with the message signalx
.y = cos(2*pi*fc*t + opt*cumsum(x))
cumsum
is a rectangular approximation of the integral ofx
.modulate
usesopt
as the constant of frequency modulation. If you do not specify theopt
parameter,modulate
uses a default ofopt = (fc/fs)*2*pi/(max(max(x)))
so the maximum frequency excursion fromfc
isfc
Hz.pm
— Phase modulation. Creates a sinusoid of frequencyfc
whose phase varies with the message signalx
.y = cos(2*pi*fc*t + opt*x)
modulate
usesopt
as the constant of phase modulation. If you do not specify theopt
parameter,modulate
uses a default ofopt = pi/(max(max(x)))
so the maximum phase excursion is π radians.pwm
— Pulse-width modulation. Creates a pulse-width modulated signal from the pulse widths inx
. The elements ofx
must be between 0 and 1, specifying the width of each pulse in fractions of a period. The pulses start at the beginning of each period, that is, they are left justified.modulate(x,fc,fs,'pwm','centered')
yields pulses centered at the beginning of each period. The length ofy
islength(x)*fs/fc
.ppm
— Pulse-position modulation. Creates a pulse-position modulated signal from the pulse positions inx
. The elements ofx
must be between 0 and 1, specifying the left edge of each pulse in fractions of a period.opt
is a scalar between 0 and 1 that specifies the length of each pulse in fractions of a period. The default foropt
is0.1
. The length ofy
islength(x)*fs/fc
.qam
— Quadrature amplitude modulation. Creates a quadrature amplitude modulated signal from signalsx
andopt
.y = x.*cos(2*pi*fc*t) + opt.*sin(2*pi*fc*t)
The input argument
opt
must be the same size asx
.
opt
— Optional input for some methods
scalar | vector | matrix
Optional input, specified for some methods. Refer to method
for
more details on how to use opt
.
Data Types: single
| double
| char
| string
Complex Number Support: Yes
Output Arguments
y
— Modulated signal
real vector | real matrix
Modulated message signal, returned as a real vector or matrix. Except for the
methods pwm
and ppm
, y
is the
same size as x
.
t
— Internal time array
real vector
Internal time array used by modulate
in its computations,
specified as a real vector.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced before R2006aR2023b: Generate C and C++ code
Generate C and C++ code for the modulate
function. You must have
MATLAB®
Coder™ to use this functionality.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)