0% found this document useful (0 votes)
8 views7 pages

MATLAB Final Exam Answers April 2021

The document contains 5 questions related to signal processing and coding. Question 1 plots bit error rate curves for different modulation schemes. Question 2 performs matrix operations and extracts submatrices. Question 3 calculates the mean of a data set and finds the correlation coefficient. Question 4 defines functions for an ODE solver. Question 5 contains no question.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

MATLAB Final Exam Answers April 2021

The document contains 5 questions related to signal processing and coding. Question 1 plots bit error rate curves for different modulation schemes. Question 2 performs matrix operations and extracts submatrices. Question 3 calculates the mean of a data set and finds the correlation coefficient. Question 4 defines functions for an ODE solver. Question 5 contains no question.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Question 1

CODE

SNR=1:5;

BPSK=[0.0190,0.0100,0.0046,0.0020,0.0008];

QPSK=[0.1316,0.0941,0.0630,0.0384,0.0202];

EIGHT_QAM=[0.0377,0.0202,0.0096,0.0041,0.0016];

SIXTEEN_QAM=[0.0478,0.0252,0.0119,0.0049,0.0018];

semilogy(SNR,BPSK,'b-O', SNR,QPSK,'r-^', SNR,EIGHT_QAM,'m-s', SNR,SIXTEEN_QAM,'k-d'),


legend('BPSK','QPSK','8QAM','16QAM'), title('BIT ERROR PERFOMANCE'), xlabel('SNR'), ylabel('BER'),
axis([1 5 10^-4 1])

BIT ERROR PERFOMANCE


10 0
BPSK
QPSK
8QAM
16QAM
10 -1
BER

10 -2

10 -3

10 -4
1 1.5 2 2.5 3 3.5 4 4.5 5
SNR

subplot(2,2,1)

semilogy(SNR,BPSK,'-O');axis([1 5 10^-4 10^-1]), xlabel('SNR'),ylabel('BER');title('BPSK');

subplot(2,2,2)

semilogy(SNR,QPSK,'r-^');axis([1 5 10^-2 1]), xlabel('SNR'),ylabel('BER');title('QPSK');


subplot(2,2,3)

semilogy(SNR,EIGHT_QAM,'m-s');axis([1 5 10^-3 10^-1]), xlabel('SNR'),ylabel('BER');title('8 QAM');

subplot(2,2,4)

semilogy(SNR,SIXTEEN_QAM,'k-d'); axis([1 5 10^-3 10^-1]), xlabel('SNR'),ylabel('BER');title('16 QAM');

BPSK QPSK
10 0 10 0
BER

BER
10 -2 10 -1

10 -4 10 -2
1 2 3 4 5 1 2 3 4 5
SNR SNR
8 QAM 16 QAM
10 -1 10 -1
BER

BER

10 -2 10 -2

10 -3 10 -3
1 2 3 4 5 1 2 3 4 5
SNR SNR

Question 2

for r=1:2

for c=1:500

a(r,c)=sqrt((2-r+1)+2*(c-1));

end

end

a
a)

for c=1:500

b(c)=a(1,c)*a(2,c);

end

b;

mean(b)

500.4991

b)

a(:,258:264)

22.7156 22.7596 22.8035 22.8473 22.8910 22.9347 22.9783

22.6936 22.7376 22.7816 22.8254 22.8692 22.9129 22.9565

c)

a(2,120:125)

15.4596 15.5242 15.5885 15.6525 15.7162 15.7797

d)

for c=1:500

d(c,c)=a(1,c);

end

d;

Question 3

x=[25;9;21;7;2;43;28;47;35;29];

xmean=mean(x)

num=0;den=0;

for i=1:10

num=num+(x(i)-xmean);

den=den+(x(i)+xmean)^2;

r(i)=num/sqrt(den);

end
r

rtotal=sum(r)

Answers

xmean = 24.6000

r = 0.0081 -0.2537 -0.2497 -0.4458 -0.6870 -0.3715 -0.3067 -0.1051 -0.0288 -0.0000

rtotal = -2.4402

Question 4

a)

function y=fcn(u)

Y=1/6*(u.*cos(u)+exp(-3*u)+1.5*u;

end

b)
function ydot=func(t,y)

ydot(1)=y(2);

ydot(2)= 1/6*(t.*cos(t)+exp(-3*t)+1.5*t+3.6*y(1));

ydot=[ydot(1);ydot(2)];
end

[t,y]=ode45(@func,[0,6],[-6,4.2]);
plot(t,y),xlabel('t'),ylabel('y'),legend('y','ydot')

c)

[t,y]=ode45(@func,[0,6],[-6,4.2]);

>> subplot(1,2,1);

>> plot(t,y),xlabel('t'),ylabel('y'),legend('y','ydot')

>> subplot(1,2,2);

>> plot(out.integ.time,out.integ.signals.values)
Question 5

You might also like