% Create a random digital message M = 16; % Alphabet size x = randint(5000,1,M); % Use 16-QAM modulation to produce y. y=modulate(modem.qammod(M),x); % Transmit signal through an AWGN channel. ynoisy = awgn(y,15,'measured'); % Create scatter plot from noisy data. scatterplot(ynoisy); % Demodulate ynoisy to recover the message. z=demodulate(modem.qamdemod(M),ynoisy; % Check symbol error rate. [num,rt]= symerr(x,z) Your numerical results and plot might vary, because the example uses random numbers. num =83 rt =0.0166 The scatter plot does not look exactly like a signal constellation. Where the signal constellation has 16 precisely located points, the noise causes the scatter plot to have a small cluster of points approximately where each constellation point would be.

AWGN Add white Gaussian noise to a signal. Y = AWGN(X,SNR) adds white Gaussian noise to to X. The SNR is in dB. The power of X is assumed to be 0 dBW. If X is complex, then then AWGN adds complex noise.

Y = AWGN(X,SNR,SIGPOWER) when SIGPOWER is numeric, it represents the signal power in dBW. When SIGPOWER is 'measured', AWGN measures the signal power before adding noise. Y = AWGN(X,SNR,SIGPOWER,STATE) resets the state of RANDN to STATE. Y = AWGN(..., POWERTYPE) specifies the units of SNR and SIGPOWER. POWERTYPE can be 'db' or 'linear'. If POWERTYPE is is 'db', then SNR is measured in dB and SIGPOWER SIGPOWER is measured in dBW. If POWERTYPE is is 'linear', then SNR is measured as a ratio and SIGPOWER is measured in Watts. Example: To specify the power of X to be 0 dBW and add noise to produce an SNR of 10dB, use: X = sqrt(2)*sin(0:pi/8:6*pi); sqrt(2)*sin(0:pi/8:6*pi); Y = AWGN(X,10,0); Example: To specify the power of X to be 0 dBW, set RANDN to the 1234th state and add noise to produce an SNR of 10dB, use: X = sqrt(2)*sin(0:pi/8:6*pi); sqrt(2)*sin(0:pi/8:6*pi); Y = AWGN(X,10,0,1234); Example: To specify the power of X to be 3 Watts and add noise to

produce a linear SNR of 4, use: X = sqrt(2)*sin(0:pi/8:6*pi); sqrt(2)*sin(0:pi/8:6*pi); Y = AWGN(X,4,3,'linear'); Example: To cause AWGN to measure the power of X, set RANDN to the 1234th state and add noise to produce a linear SNR of 4, use: X = sqrt(2)*sin(0:pi/8:6*pi); sqrt(2)*sin(0:pi/8:6*pi); Y = AWGN(X,4,'measured',1234,'linear')

PMMOD Phase modulation. Y = PMMOD(X,Fc,Fs,PHASEDEV) uses the message signal X to phase modulate the carrier frequency Fc (Hz). Fc and X have sample frequency Fs (Hz), where Fs >= 2*Fc. PHASEDEV (radians) is the frequency deviation of the modulated signal.

Y = PMMOD(X,Fc,Fs,PHA PMMOD(X,Fc,Fs,PHASEDEV,INI_PHASE) SEDEV,INI_PHASE) specifies the initial phase (radians) of the modulated signal. See also pmdemod, fmmod, fmdemod. Reference page in Help browser doc pmmod

LEGEND Display legend. LEGEND(string1,string2,string3, LEGEND(string1,string2,st ring3, ...) puts a legend on the current plot using the specified strings as labels. LEGEND works on line graphs, bar graphs, pie graphs, ribbon plots, etc. You can label any solid-colored patch or surface object. The fontsize and fontname fontname for the legend strings matches the axes fontsize and fontname.

LEGEND(H,string1,string2,string3, ...) puts a legend on the plot containing the handles in the vector H using the specified strings as labels for the corresponding handles. LEGEND(M), where M is a string matrix or cell array of strings, and LEGEND(H,M) where H is a vector of handles to lines and patches also works. LEGEND(AX,...) puts a legend on the axes with handle AX. LEGEND OFF removes the legend from the current axes and deletes the legend handle. LEGEND(AX,'off') removes the legend from the axis AX. LEGEND TOGGLE toggles legend on or off. If no legend exists for the current axes one is created using default d efault strings. The default string for an object is the value of o f the DisplayName property

if it is non-empty and otherwise it is a string of the form 'data1','data2', etc. LEGEND(AX,'toggle') toggles legend for axes AX LEGEND HIDE makes legend invisible. LEGEND(AX,'hide') makes legend on axes AX invisible. LEGEND SHOW makes legend visible. If no legend exists for the current axes one is created using default d efault strings. LEGEND(AX,'show') makes legend on axes AX visible. LEGEND BOXOFF makes legend background box invisible invisible when legend is visible. LEGEND(AX,'boxoff') for axes AX makes legend background box invisible when legend is visible. LEGEND BOXON makes legend background box visible when legend is visible. LEGEND(AX,'boxon') for axes AX making legend background box visible when legend is visible. LEGH = LEGEND returns the handle to legend on the current axes or empty if none exists. LEGEND with no arguments refreshes all the legends in the current figure (if any). LEGEND(LEGH) refreshes the specified legend. LEGEND(...,'Location',LOC) adds a legend in the specified location, LOC, with respect to to the axes. LOC may be either a 1x4 position vector or one of the following strings: 'North' inside plot box near top 'South' inside bottom 'East' inside right 'West' inside left 'NorthEast' inside top right (default) 'NorthWest inside top left 'SouthEast' inside bottom right 'SouthWest' inside bottom left 'NorthOutside' outside plot box near top 'SouthOutside' outside bottom 'EastOutside' outside right 'WestOutside' outside left 'NorthEastOutside' outside top right 'NorthWestOutside' outside top left 'SouthEastOutside' outside bottom right 'SouthWestOutside' outside bottom left 'Best' least conflict with data in plot 'BestOutside' least unused space outside plot LEGEND(...,'Orientation',ORIENTATION) creates a legend with the legend items arranged in the specified ORIENTATION. Allowed values for ORIENTATION are 'vertical' (the default) and 'horizontal'.

[LEGH,OBJH,OUTH,OUTM] = LEGEND(...) returns a handle LEGH to the legend axes; a vector OBJH containing con taining handles for the text, lines, and patches in the legend; a vector OUTH of handles to the lines and patches in the plot; and a cell array OUTM containing the text in the legend. Examples: x = 0:.2:12; plot(x,bessel(1,x),x,bessel(2,x),x,bessel(3,x)); legend('First','Second','Third'); legend('First','Second','Third','Location','NorthEastOutside') b = bar(rand(10,5),'stacked'); colormap(summer); hold on x = plot(1:10,5*rand(10,1),'marker','square','markersize',12,... 'markeredgecolor','y','markerfacecolor',[.6 0 .6],... 'linestyle','-','color','r','linewidth',2); 'linestyle','-','color','r','li newidth',2); hold off legend([b,x],'Carrots','Peas','Peppers','Green Beans',... 'Cucumbers','Eggplant')

RANDINT Generate matrix of uniformly distributed random integers . OUT = RANDINT generates a "0" or "1" with equal probability.

OUT = RANDINT(M) generates an M-by-M matrix of random binary numbers. "0" and "1" occur with equal probability. OUT = RANDINT(M,N) generates an M-by-N matrix of random binary numbers. "0" and "1" occur with equal probability. OUT = RANDINT(M,N,RANGE) generates an M-by-N matrix of random integers. RANGE can be either a scalar or a two-element vector: Scalar : If RANGE is a positive integer, then the output integer range is [0, RANGE-1]. If RANGE is a negative integer, integer, then the output integer range is [RANGE+1, 0]. Vector : If RANGE is a two-element vector, then the output integer range is [RANGE(1), RANGE(2)]. OUT = RANDINT(M,N,RANGE,STATE) resets the state of RAND to STATE. Examples: » out = randint(2,3) out = 0 0 1 1 0 1 » out = randint(2,3,-4)

» out = randint(2,3,4) out = 1 0 3 2 3 1 » out = randint(2,3,[-2 2])

out = -3 -1 -2 0

-2 0

out = -1 0 1 2

-2 1

See also rand, randsrc, randerr. Reference page in Help browser doc randint

MODULATE Signal modulation for communications communications simulations . Y = MODULATE(X,Fc,Fs,METHOD,OPT) modulates the message signal X with a carrier frequency Fc and sampling frequency Fs, using the modulation scheme in METHOD. OPT is an extra extra sometimes optional parameter whose purpose depends on the modulation scheme you choose.

Fs must satisfy Fs > 2*Fc + BW, where BW is the bandwidth of the modulated signal. METHOD MODULATION SCHEME 'am', Amplitude modulation, double side-band, suppressed carrier 'amdsb-sc' OPT not used. 'amdsb-tc' Amplitude modulation, double side-band, transmitted carrier OPT is a scalar which is subtracted from X prior to multiplication by the carrier cosine. It defaults to min(min(X)) so the offset message signal is positive and has a minimum value of zero. 'amssb' Amplitude modulation, single side-band OPT not used. 'fm' Frequency modulation OPT is a scalar which specifies the constant of frequency modulation kf. kf = (Fc/Fs)*2*pi/max(max(abs (Fc/Fs)*2*pi/max(max(abs(X))) (X))) by default for a maximum frequency excursion of Fc Hertz. 'pm' Phase modulation OPT is a scalar which specifies the constant of phase modulation kp. kp = pi/max(max(abs(x))) pi/max(max(abs(x))) by default default for a maximum phase excursion of +/-pi radians. 'pwm' Pulse width modulation If you let OPT = 'centered', the pulses are centered on the carrier period rather than being "left justified". 'ppm' Pulse position modulation OPT is a scalar between 0 and 1 which specifies the pulse width in fractions of the carrier period. It defaults to .1. 'qam' Quadrature amplitude modulation OPT is a matrix the same size as X which is modulated in quadrature with X. If X is a matrix, its columns are modulated.

[Y,T] = MODULATE(...) returns a time vector the same length as Y. See also demod, vco in the Signal Processing Toolbox, and pamdemod, qamdemod, genqamdemod, fskdemod, psmdemod, mskdemod in the Communications Toolbox. Overloaded functions or methods (ones with the same name in other directories) help laurpoly/modulate.m Reference page in Help browser doc modulate

DEMOD Signal demodulation for communications simulations. X = DEMOD(Y,Fc,Fs,METHOD,OPT) demodulates the carrier signal Y with a carrier frequency Fc and sampling frequency Fs, using the demodulation scheme in METHOD. OPT is an extra, extra, sometimes optional, parameter whose purpose depends on the demodulation scheme you choose.

Fs must satisfy Fs > 2*Fc + BW, where BW is the bandwidth of the modulated signal. METHOD DEMODULATION SCHEME 'am', Amplitude demodulation, double side-band, suppressed carrier 'amdsb-sc' OPT not used. 'amdsb-tc' Amplitude demodulation, double side-band,transmitted carrier OPT is a scalar which is subtracted from the decoded message signal. It defaults defaults to zero. 'amssb' Amplitude demodulation, single side-band OPT not used. 'fm' Frequency demodulation OPT is a scalar which specifies the constant of frequency modulation kf, which defaults to 1. 'pm' Phase demodulation OPT is a scalar which specifies the constant of phase modulation kp, which defaults to 1. 'pwm' Pulse width demodulation By setting OPT = 'centered' you tell DEMOD that the pulses are centered on the carrier period rather than being "left justified". 'ppm' Pulse position demodulation OPT is not used. 'qam' Quadrature amplitude demodulation For QAM signals, use [X1,X2] = DEMOD(Y,Fc,Fs,'qam') If Y is a matrix, its columns are demodulated. See also modulate in the Signal Processing Toolbox, and pamdemod,

qamdemod, genqamdemod, fskdemod, psmdemod, mskdemod in the Communications Toolbox. Reference page in Help browser

Our partners will collect data and use cookies for ad personalization and measurement. Learn how we and our ad partner Google, collect and use data. Agree & close