matlab bpsk
Hi friend: see this for matlab below 2008 version
Simple Digital Modulation Example
This example illustrates the basic format of the baseband modulation and
demodulation commands,
dmodce and ddemodce. Although the example uses the PSK method, most elements of this example apply to digital modulation techniques other than PSK.
The example generates a random digital signal, modulates it, and adds noise.
Then it creates a scatter plot, demodulates the noisy signal, and computes the
symbol error rate. The ddemodce function demodulates the analog signal y and
then demaps to produce the digital signal z.
Notice that the scatter plot does not look exactly like a signal constellation.
Whereas the signal constellation would have 16 precisely located points, the
noise causes the scatter plot to have a small cluster of points approximately
where each constellation point would be. However, the noise is sufficiently
small that the signal can be recovered perfectly. Below are the code and the scatter plot.
M = 16; % Use 16-ary modulation.
Fd = 1; % Assume the original message is sampled
% at a rate of 1 sample per second.
Fs = 3; % The modulated signal will be sampled
% at a rate of 3 samples per second.
x = randint(100,1,M); % Random digital message
% Use M-ary PSK modulation to produce y.
y = dmodce(x,Fd,Fs,'psk',M);
% Add some Gaussian noise.
ynoisy = y + .04*randn(300,1) + .04*j*randn(300,1);
% Create scatter plot from noisy data.
scatterplot(ynoisy,1,0,'b.');
% Demodulate y to recover the message.
z = ddemodce(ynoisy,Fd,Fs,'psk',M);
s = symerr(x,z) % Check symbol error rate.
s =
0
Customizing the Modulation Process
the modulation and demodulation processes each consist of two steps. You can tell the toolbox functions to carry out only selected steps in the processes. For example, this might be useful if you want to use standard mapping and demapping
techniques along with unusual or proprietary modulation and demodulation techniques.
Mapping Without Modulating and Demapping Without Demodulating
To map the digital signal to an analog signal without modulating the analog
signal, use the modmap function instead of the dmodce function. To demap the
analog signal to a digital signal without demodulating the analog signal, use
the demodmap function instead of the ddemodce function.
To alter the basic example so that it does not modulate or demodulate the
analog signals at all, replace the “old commands” listed in the first column of
the table below with the “new commands” listed in the second column.
Modulating Without Mapping and Demodulating Without Demapping
To carry out the analog modulation step on a signal that has already been
mapped from a digital signal to an analog signal, use the dmodce function with
the extra word /nomap appended to the method string. To carry out the analog
demodulation step but avoid demapping the resulting signal to a digital signal,
use the ddemodce function with the extra word /nomap appended to the method
string.
If you substituted your own mapping and demapping steps into the basic
example then it would look something like the code below. The lines in the
second grouping differ from the original example.
M = 16; % Use 16-ary modulation.
Fd = 1; % Assume the original message is sampled
% at a rate of 1 sample per second.
Fs = 3; % The modulated signal will be sampled
% at a rate of 3 samples per second.
x = randint(100,1,M); % Random digital message
% Important changes are below.
mapx = mymappingfunction(x); % Use your own function here.
y = dmodce(mapx,Fd,Fs,'psk/nomap',M); % Modulate without mapping.
% Demodulate y without demapping.
demody = ddemodce(y,Fd,Fs,'psk/nomap',M);
% Now demap.
z = mydemappingfunction(demody); % Use your own function here.
Other Options in Digital Modulation
The table below lists a few ways in which you might vary the example in
“Simple Digital Modulation Example” on page 2-77 in order to perform the
modulation and demodulation slightly differently. See the reference pages for
full details about options.
Good luck