You are on page 1of 6

GIAI DE THI

Đề D09
Đề 3;

Bài 1:
% V1=5;=> V1 – 5=0;
% 6(V2-V1)+ V2 + 3(V2-V3)=0; => -6V1 + 10V2 -3V3=0
% (V3-V2)+ 50V3 =0 => -V2 +51V3=0;
function F = fun(V)%Khoi tao ham
F = [V(1) - 5;
-6*V(1) + 10*V(2) - 3*V(3);
-V(2) + 51*V(3);];
End

V123 = [0; 0; 0]; %Gia tri khoi tao


[V123] = fsolve(@fun,V123) %Goi ham fsolve

Bài 2:
clear all; close all; clc;
K=0.5;
t0=0; t1=2;
h=0.25;
y(1)=0;
t=t0:h:t1;
for k=2:length(t)
y(k)=y(k-1)+h*(1-K*sin(y(k-1)));
end;
plot(t,y,'r*');

Bài 3:
function [t,y]=ham(f1,f2,fs)
ts=1/fs;
t=0:ts:5/f2;
y1=cos(2*pi*f1*t);
y2=cos(2*pi*f2*t+pi/4);
y=y1+y2;
end
Bài 4:

close all; clear all; clc;


f1=10;f2=15;fs=16*f2;
snr=8;%dB
[t,y]=ham(f1,f2,fs);
Ps=var(y);
N0=Ps/(10^(snr/10));
r=y+sqrt(N0)*randn(size(y));
y_awgn=awgn(y,8,'measured');
% subplot(211);
plot(t,y,'r','LineWidth',2);title('tin hieu goc'); hold
on;
% subplot(212);
plot(t,y_awgn, 'g'); title('tin hieu sau nhieu'); hold
on;
% figure;
plot(t,r,'k');

Đề 1:

Bài 1:

Bài 2:
clear all; close all; clc;
t0=0; t2=2;
h=0.25;
y(1)=0;
t=t0:h:t2;
for k=2:length(t)
y(k)=y(k-1)+h*(1-(y(k-1))^2);
end;
plot(t,y,'r*');

Bài 3:
function [t,y]=xungtamgiac(R,fs,Np)
ts=1/fs;Tp=1/R;
t=0:ts:Np*Tp;
tn=mod(t,Tp);
y=1-abs((2*tn-Tp)/Tp);
plot(t,y);
end

Bài 4:
close all; clear all; clc;
M=4;N=1000;
d=randint(1,N,M);
s=pskmod(d,M,pi/4);
scatterplot(s,1,0,'or');

Đề D10
Đề 2
Bài 1:
A=[1 2 3 2; 3 7 6 2; 4 5 2 1];
B=A.*(mod(A,2)==0)

Bài 2:

clear all; close all; clc;


t0=0; t1=3;
h=0.25;
y(1)=2/3;
t=t0:h:t1;
for k=2:length(t)
y(k)=y(k-1)+h*(y(k-1)-(k-1));
end;
plot(t,y,'r*');

Bài 3:
function [t,y]=chuoixung(R,Np)
% R toc do xung
% Np so luong xung trong chuoi
% t, y la cac vector thoi gian va mau chuoi tin hieu
dau ra
fs=16*R;
Tp=1/R;
ts=1/fs;
Tw=Np*Tp;
t=0:ts:Tw;
tn=mod(t,Tp);
y=exp(-4*tn/Tp);
plot(t,y,'r')
end

Bài 4:
clear all;clc;
M=4; N=1000;
SNR=10;
d=randint(1,N,M);
s=qammod(d,M);
sawgn=awgn(s,10,'measured');
h=scatterplot(sawgn,1,0,'or');
hold on;
scatterplot(s,1,0,'k',h);

Đề 1

Bài 1:
clear, close all; clc;
x=[0.2 0.3 0.5 0.8 0.3 0.4 0.1 0.5 0.3 0.2];
d=x>=0.3 % so sanh "lon hon hoac bang";tra ve "1" neu
true "0" neu false
x(mod(x,0.3)==0)=1 % neu x chia 0.3 du bang "0" thi x=1
e=x~=d % so sanh "khong bang" "1" neu true; "0" neu
false

Bài 2:
function [y]=arctan(x)
e=1e-4;
n=0; m=0;
test=1;%(-1)^n/(2*n+1)*x^(2*n+1);
while abs(test)>e
test=(-1)^n/(2*n+1)*x^(2*n+1);
n=n+1;
m=m+test;
%test=(-1)^n/(2*n+1)*x^(2*n+1);
end
fprintf('so vong lap la: %d\n', n);
y=m;

Bài 3:
function [t,y]=chuoixung(R,Np)
% R toc do xung
% Np so luong xung trong chuoi
% t, y la cac vector thoi gian va mau chuoi tin hieu
dau ra
fs=16*R;
Tp=1/R;
ts=1/fs;
Tw=Np*Tp;
t=0:ts:Tw;
tn=mod(t,Tp);
y=exp(-4*tn/Tp);
plot(t,y,'r')
end

Bài 4:
clear all; clc; close all;
M=4; N=1000; snr=10;
d=randint(1,N,M);
y=pskmod(d,M);
Py=var(y);
Ps=10*log10(Py);
y_awgn=awgn(y,snr,Ps);
y_noi=awgn(y,snr,'measured');
h=scatterplot(y,1,0,'ro');
hold on;
scatterplot(y_awgn,1,0,'.',h);
hold off;
legend('Tin hieu phat','Tin hieu thu');
scatterplot(y_noi,1,0);
Mình tổng hợp của bạn bè. Mọi người xem rồi có gì sửa mình với. 

You might also like