Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB Exercises We wish to transmit the following 20 bits of data, using variou

ID: 2268745 • Letter: M

Question

MATLAB Exercises We wish to transmit the following 20 bits of data, using various modulation schemes: [100 11 10 11 0000 10 11101] 1. Using a data rate of 1 bit per second, a carrier of 5 Hz., and a sampling frequency of 50 samples per second, create a MATLAB plot of the OOK modulated signal, along with a plot of the PSD of the signal. Use the functions plot fft_spectrum.m and fft_spectrum.m as a starting point, and modify as necessary. Repeat for BPSK Now create an FSK respectively 2. 3. modulation of the same signal, using 4 Hz and 6 Hz to represent binary zeros and ones

Explanation / Answer

1. OOK stands for On/Off keying.It is a basic form of amplitude shift keying modulation;commonly used to transmit Morse code over radio frequenciesd. PSD stands for Power spectral density.Below is the MATLAB code for ook and psd

x_data=[10011101100001011101] ;%the complete data set

l_data=length(x_data);

speed_data=input('the speed of data transmission');

num_data=input('the number of data points to transmit');

duty_data=input('duty ratio for RZ pulse,less than 1");

times_data=input('number of times want to transmit data');

fs=input('sampling frequency');

i=0;

while(j<(2^l_data-1))

y=xor(x_data(19),x_data(20));

temp_data=[y,x_data];

x_data=temp_data;

j=length(x_data);

end

data(1:num_data)=zeros;

while(i<num_data)

dgen(i+1:i+j)=x_data;

i=length(dgen);

if(i>num_data)

data(1:num_data)=dgen(1:num_data);

clear dgen temp

t=(1/(32*speed_data))*(1:1(32*num_data));

end

end

%for pulse generation

nr(1:32)=ones;

rz(1:32)=zeros;

lower=nearest(duty_data*32);

rz(1:lower)=ones;

new1=kron(data,nr);

new2=kron(data,rz);

%plotting command

subplot(2,1,1),plot(t,new1);hold

grid minor

subplot(2,1,2),plot(t,new2);hold

grid minor

%Power Spectral Density Calculation

xdft_data=fft(x_data);

xdft_data=xdft(1:(l_data/2)+1);

psdx_data=(1/(fs*l_data))*abs(xdft_data).^2;

psdx_data(2:end-1)=2*psdx_data(2:end-1);

frequency=0:fs/l_data:fs/2;

figure(2)

plot(frequency,10*log10(psdx_data))

grid on

2. clear all;

close all;

%Nb is the number of bits to be transmitted

Time=1;%Bit rate is assumed to be 1 bit/s;

%bits to be transmitted

x_data=[10011101100001011101] ;

%Rb is the bit rate in bits/second

NRZ_out=[];

RZ_out=[];

Manchester_out=[];

  

%Vp is the peak voltage +v of the NRZ waveform

Vp=1;

%Here we encode input bitstream as Bipolar NRZ-L waveform

for index=1:size(b,2)

if x_data(index)==1

NRZ_out=[NRZ_out ones(1,200)*Vp];

elseif x_data(index)==0

NRZ_out=[NRZ_out ones(1,200)*(-Vp)];

end

end

%Generated bit stream impulses

figure(1);

stem(x_data);

xlabel('Time (seconds)-->')

ylabel('Amplitude (volts)-->')

title('Impulses of bits to be transmitted');

figure(2);

plot(NRZ_out);

xlabel('Time (seconds)-->');

ylabel('Amplitude (volts)-->');

title('Generated NRZ signal');

t=0.005:0.005:5;

%Frequency of the carrier

f=5;

%Here we generate the modulated signal by multiplying it with

%carrier (basis function)

Modulated=NRZ_out.*(sqrt(2/T)*cos(2*pi*f*t));

figure;

plot(Modulated);

xlabel('Time (seconds)-->');

ylabel('Amplitude (volts)-->');

title('BPSK Modulated signal');

clear all;

close all;

x_data=[10011101100001011101];                                    % Binary Information

l_data=length(x_data);

bp_data=.000001;                                                    % bit period

disp(' Binary information at Transmitter :');

disp(x_data);

%representation of transmitting binary information as digital signal

bit_data=[];

for n=1:1:l_data

    if x(n)==1;

       se_data=ones(1,100);

    else x(n)==0;

        se_data=zeros(1,100);

    end

     bit_data=[bit se];

end

t1=bp_data/100:bp_data/100:100*length(x_data)*(bp_data/100);

subplot(3,1,1);

plot(t1,bit_data,'lineWidth',2.5);grid on;

axis([ 0 bp_data*length(x_data) -.5 1.5]);

ylabel('amplitude(volt)');

xlabel(' time(sec)');

title('transmitting information as digital signal');

Amp=5;                                          % Amplitude of carrier signal

br_data=1/bp_data;                                                         % bit rate

f1_data=br_data*4;                           % carrier frequency for information as 1

f2_data=br_data*6;                           % carrier frequency for information as 0

t2_data=bp_data/99:bp_data/99:bp_data;                

ss=length(t2_data);

m=[];

for (i=1:1:length(x_data))

    if (x_data(i)==1)

        y=A*cos(2*pi*f1_data*t2);

    else

        y=A*cos(2*pi*f2_data*t2);

    end

    m=[m y];

end

t3=bp_data/99:bp_data/99:bp_data*length(x_data);

subplot(3,1,2);

plot(t3,m);

xlabel('time(sec)');

ylabel('amplitude(volt)');

title('waveform for binary FSK modulation coresponding binary information’)

1. OOK stands for On/Off keying.It is a basic form of amplitude shift keying modulation;commonly used to transmit Morse code over radio frequenciesd. PSD stands for Power spectral density.Below is the MATLAB code for ook and psd

x_data=[10011101100001011101] ;%the complete data set

l_data=length(x_data);

speed_data=input('the speed of data transmission');

num_data=input('the number of data points to transmit');

duty_data=input('duty ratio for RZ pulse,less than 1");

times_data=input('number of times want to transmit data');

fs=input('sampling frequency');

i=0;

while(j<(2^l_data-1))

y=xor(x_data(19),x_data(20));

temp_data=[y,x_data];

x_data=temp_data;

j=length(x_data);

end

data(1:num_data)=zeros;

while(i<num_data)

dgen(i+1:i+j)=x_data;

i=length(dgen);

if(i>num_data)

data(1:num_data)=dgen(1:num_data);

clear dgen temp

t=(1/(32*speed_data))*(1:1(32*num_data));

end

end

%for pulse generation

nr(1:32)=ones;

rz(1:32)=zeros;

lower=nearest(duty_data*32);

rz(1:lower)=ones;

new1=kron(data,nr);

new2=kron(data,rz);

%plotting command

subplot(2,1,1),plot(t,new1);hold

grid minor

subplot(2,1,2),plot(t,new2);hold

grid minor

%Power Spectral Density Calculation

xdft_data=fft(x_data);

xdft_data=xdft(1:(l_data/2)+1);

psdx_data=(1/(fs*l_data))*abs(xdft_data).^2;

psdx_data(2:end-1)=2*psdx_data(2:end-1);

frequency=0:fs/l_data:fs/2;

figure(2)

plot(frequency,10*log10(psdx_data))

grid on