Tìm hiểu mô phỏng hệ thống MIMO - OFDM và đánh giá chất lượng hệ thống - 11

zero_pad_sym(k,1:Nos:Nc*Nos) = mod_sym(k,:); end

sub_block=zeros(Nsb,NNos);

for k=1:Nsb % chia thanh cac khoi con theo 5.9 kk = (k-1)*NNos/Nsb+1:k*NNos/Nsb; sub_block(k,kk) = zero_pad_sym(1,kk);

end

ifft_sym=ifft(sub_block.',NNos).'; % IFFT

% -- toi uu hoa he so pha – % for m=1:Nsb

x = w(1:Nsb)*ifft_sym; % pt 5.10

sym_pow = abs(x).^2; PAPR = max(sym_pow)/mean(sym_pow); if m==1, PAPR_min = PAPR;

else if PAPR_min<PAPR, w(m)=1; else PAPR_min = PAPR; end end

w(m+1)=-1;

Có thể bạn quan tâm!

Xem toàn bộ 97 trang tài liệu này.

end

x_tilde = w(1:Nsb)*ifft_sym; % pt 5.12: tim pha nho nhat sym_pow = abs(x_tilde).^2; % cong suat ky hieu PAPRs(nblk) = max(sym_pow)/mean(sym_pow);

Tìm hiểu mô phỏng hệ thống MIMO - OFDM và đánh giá chất lượng hệ thống - 11

end PAPRdBs=10*log10(PAPRs);

dBcs = dBs + (dBs(2)-dBs(1))/2; count=0; N_bins=hist(PAPRdBs,dBcs);

for i=length(dBs):-1:1, count=count+N_bins(i); CCDF(i)=count/Nblk; end

2. Hệ thống Alamouti_BER Alamouti

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA) frmLen = 100; % chieu dai frame

numPackets = 1000; % so luong packets

EbNo = 0:2:20; % gia tri thay doi Eb/No den 20dB

N = 2; % so luong anten phat Tx

M = 2; % so luong anten thu Rx

P = 4; % dang dieu che

qpskmod = modem.pskmod('M', P, 'SymbolOrder', 'Gray'); qpskdemod = modem.pskdemod(qpskmod);

% ma tran khoi tao

tx2 = zeros(frmLen, N); H = zeros(frmLen, N, M);

r21 = zeros(frmLen, 2); r12 = zeros(frmLen, 2);r22 = zeros(frmLen, 2,2); z21 = zeros(frmLen, 1); z21_1 = zeros(frmLen/N, 1); z21_2 = z21_1;

z12 = zeros(frmLen, M); z22_1 = zeros(frmLen/N, 1); z22_2 = z22_1; z22 = zeros(frmLen, 2);zr22 = zeros(frmLen, 1);

error11 = zeros(1, numPackets); BER11 = zeros(1, length(EbNo));

error21 = error11; BER21 = BER11; error12 = error11; BER12 = BER11; BERthy2 = BER11;

% vong lap cho ebNo diem for idx = 1:length(EbNo)

% vong lap cho so luong packet for packetIdx = 1:numPackets

data = randint(frmLen, 1, P); % du lieu

tx = modulate(qpskmod, data); % dieu che QPSK

% khoi tao figure cho ket qua BER h = gcf; grid on; hold on;

f1=figure(1); set(f1,'color',[1 1 1])

set(gca, 'yscale', 'log', 'xlim', [EbNo(1), EbNo(end)], 'ylim', [1e-5 1]);

xlabel('Eb/No (dB)'); ylabel('BER'); set(h,'NumberTitle','off');

set(h, 'renderer', 'zbuffer'); set(h,'Name','he thong da anten'); title('he thong da anten');

s1 = tx(1:N:end); s2 = tx(2:N:end);

tx2(1:N:end, :) = [s1 s2]; tx2(2:N:end, :) = [-conj(s2) conj(s1)]

% tx2 = [tx tx];

% ma tran kenh truyen

H(1:N:end, :, :) = (randn(frmLen/2, N, M) + ... j*randn(frmLen/2, N, M))/sqrt(2);

H(2:N:end, :, :) = H(1:N:end, :, :);

% tin hieu thu

% he thong 1x1

r11 = awgn(H(:, 1, 1).*tx, EbNo(idx));

% he thong 2x1

r21 = awgn(sum(H(:, :, 1).*tx2, 2)/sqrt(N), EbNo(idx));

% he thong 1x2 va 2x2 for i = 1:M

r12(:, i) = awgn(H(:, 1, i).*tx, EbNo(idx));

r22(:, i) = awgn(sum(H(:, :, i).*tx2, 2)/sqrt(N), EbNo(idx));

end

% tin hieu tong cua ht 2x1

%z21=sum(r21.*conj(H(:,:,1)),2); hidx = 1:N:length(H);

z21_1 = r21(1:N:end).* conj(H(hidx, 1, 1)) + ...

conj(r21(2:N:end)).* H(hidx, 2, 1);

z21_2 = r21(1:N:end).* conj(H(hidx, 2, 1)) - ...

conj(r21(2:N:end)).* H(hidx, 1, 1); z21(1:N:end) = z21_1; z21(2:N:end) = z21_2;

% he thong 1x2

for i = 1:M

z12(:, i) = r12(:, i).* conj(H(:, 1, i));

z22_1(:, i) = r22(1:N:end,i).* conj(H(hidx, 1, i)) + ... conj(r22(2:N:end,i)).* H(hidx, 2, i);

z22_2 (:, i)= r22(1:N:end,i).* conj(H(hidx, 2, i)) - ... conj(r22(2:N:end,i)).* H(hidx, 1, i);

end

z22(1:N:end, :) = z22_1; z22(2:N:end,:) = z22_2;

% zr22=z22(:,1)+z22(:,2);

% giai dieu che ML (minimum Euclidean distance) demod11 = demodulate(qpskdemod, r11.*conj(H(:, 1, 1))); demod21 = demodulate(qpskdemod, z21);

demod12 = demodulate(qpskdemod, sum(z12, 2)); demod22 = demodulate(qpskdemod, sum(z22,2));

% xac dinh loi

error11(packetIdx) = biterr(demod11, data); error21(packetIdx) = biterr(demod21, data); error12(packetIdx) = biterr(demod12, data);

in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA) frmLen = 100; % chieu dai frame

numPackets = 1000; % so luong packets

EbNo = 0:2:20; % gia tri thay doi Eb/No den 20dB N = 4; % so luong anten phat Tx

M = 4; % so luong anten thu Rx

P = 4; % dang dieu che

qpskmod = modem.pskmod('M', P, 'SymbolOrder', 'Gray'); qpskdemod = modem.pskdemod(qpskmod);

% ma tran khoi tao

tx2 = zeros(frmLen, N); H = zeros(frmLen, N, M);

r21 = zeros(frmLen, 2); r12 = zeros(frmLen, 2);r22 = zeros(frmLen, 2,2); z21 = zeros(frmLen, 1); z21_1 = zeros(frmLen/N, 1); z21_2 = z21_1;

z12 = zeros(frmLen, M); z22_1 = zeros(frmLen/N, 1); z22_2 = z22_1; z22 = zeros(frmLen, 2);zr22 = zeros(frmLen, 1);

error11 = zeros(1, numPackets); BER11 = zeros(1, length(EbNo));

error21 = error11; BER21 = BER11; error12 = error11; BER12 = BER11; BERthy2 = BER11;

% vong lap cho ebNo diem for idx = 1:length(EbNo)

% vong lap cho so luong packet for packetIdx = 1:numPackets

data = randint(frmLen, 4, P); % du lieu

X = modulate(qpskmod, data); % dieu che QPSK

% khoi tao figure cho ket qua BER f2=figure(2);

set(f2,'color',[1 1 1])

h = gcf; grid on; hold on;

set(gca, 'yscale', 'log', 'xlim', [EbNo(1), EbNo(end)], 'ylim', [1e-5 1]);

xlabel('Eb/No (dB)'); ylabel('BER'); set(h,'NumberTitle','off');

set(h, 'renderer', 'zbuffer'); set(h,'Name','he thong MIMO 4x4'); title('he thong MIMO 4x4');

x0=X(:,1);

x1=X(:,1:4);

x2(:,1)=-X(:,2); x2(:,2)=X(:,1); x2(:,3)=-X(:,4);x2(:,4)=X(:,3);

x3(:,1)=-X(:,3); x3(:,2)=X(:,4); x3(:,3)=X(:,1);x3(:,4)=-X(:,2);

x4(:,1)=-X(:,4); x4(:,2)=-X(:,3); x4(:,3)=X(:,2);x4(:,4)=X(:,1);

x5=conj(x1); x6=conj(x2); x7=conj(x3); x8=conj(x4);

% ma tran kenh truyen

Hr=(randn(frmLen,N,4)+j*randn(frmLen,N,4))/sqrt(2); for n=1:4

%ma tran phat

H=reshape(Hr(:,:,n),frmLen,N);

%tin hieu tren anten thu r1(:,n)=awgn(sum(H.*x1,2)/sqrt(N),EbNo(idx));%+sqrt(sigma)*(randn(frmLen,1)+j*ra ndn(frmLen,1)); r2(:,n)=awgn(sum(H.*x2,2)/sqrt(N),EbNo(idx));%+sqrt(sigma)*(randn(frmLen,1)+j*ra ndn(frmLen,1)); r3(:,n)=awgn(sum(H.*x3,2)/sqrt(N),EbNo(idx));%+sqrt(sigma)*(randn(frmLen,1)+j*ra ndn(frmLen,1)); r4(:,n)=awgn(sum(H.*x4,2)/sqrt(N),EbNo(idx));%+sqrt(sigma)*(randn(frmLen,1)+j*ra ndn(frmLen,1)); r5(:,n)=awgn(sum(H.*x5,2)/sqrt(N),EbNo(idx));%+sqrt(sigma)*(randn(frmLen,1)+j*ra ndn(frmLen,1)); r6(:,n)=awgn(sum(H.*x6,2)/sqrt(N),EbNo(idx));%+sqrt(sigma)*(randn(frmLen,1)+j*ra ndn(frmLen,1)); r7(:,n)=awgn(sum(H.*x7,2)/sqrt(N),EbNo(idx));%+sqrt(sigma)*(randn(frmLen,1)+j*ra ndn(frmLen,1)); r8(:,n)=awgn(sum(H.*x8,2)/sqrt(N),EbNo(idx));%+sqrt(sigma)*(randn(frmLen,1)+j*ra ndn(frmLen,1));

% giai dieu che tin hieu thu z1_1(:,n)=r1(:,n).*conj(H(:,1))+r2(:,n).*conj(H(:,2))+r3(:,n).*conj(H(:,3))+r4(:,n).*conj (H(:,4));

z1_2(:,n)=conj(r5(:,n)).*H(:,1)+conj(r6(:,n)).*H(:,2)+conj(r7(:,n)).*H(:,3)+conj(r8(:,n)).

*H(:,4); z1(:,n)=z1_1(:,n)+z1_2(:,n);

z2_1(:,n)=r1(:,n).*conj(H(:,2))-r2(:,n).*conj(H(:,1))-

r3(:,n).*conj(H(:,4))+r4(:,n).*conj(H(:,3));

z2_2(:,n)=conj(r5(:,n)).*H(:,2)-conj(r6(:,n)).*H(:,1)-

conj(r7(:,n)).*H(:,4)+conj(r8(:,n)).*H(:,3); z2(:,n)=z2_1(:,n)+z2_2(:,n);

z3_1(:,n)=r1(:,n).*conj(H(:,3))+r2(:,n).*conj(H(:,4))-r3(:,n).*conj(H(:,1))- r4(:,n).*conj(H(:,2));

z3_2(:,n)=conj(r5(:,n)).*H(:,3)+conj(r6(:,n)).*H(:,4)-conj(r7(:,n)).*H(:,1)- conj(r8(:,n)).*H(:,2);


end


%

z3(:,n)=z3_1(:,n)+z3_2(:,n);

z4_1(:,n)=r1(:,n).*conj(H(:,4))-r2(:,n).*conj(H(:,3))+r3(:,n).*conj(H(:,2))- r4(:,n).*conj(H(:,1));

z4_2(:,n)=conj(r5(:,n)).*H(:,4)-conj(r6(:,n)).*H(:,3)+conj(r7(:,n)).*H(:,2)- conj(r8(:,n)).*H(:,1);

z4(:,n)=z4_1(:,n)+z4_2(:,n);


r(:,1)=sum(z1,2);

r(:,2)=sum(z2,2);

r(:,3)=sum(z3,2);

r(:,4)=sum(z4,2);

demod22 = demodulate(qpskdemod,r);

% xac dinh loi


in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA) clear all, close all;

nt_V = [1 2 1 2 4 8];

nr_V = [1 1 2 2 4 8];

N0 = 1e-4; % cong suat nhieu Iteration = 1e4;

SNR_V_db = [-20:5:20];

SNR_V = 10.^(SNR_V_db/10);

color = ['b';'g';'r';'y';'b';'c'];

notation = ['-o';'->';'<-';'-^';'-s';'-*'];

for(k = 1 : length(nt_V))

nt = nt_V(k); nr = nr_V(k);

for(i = 1 : length(SNR_V))

Pt = N0 * SNR_V(i); % cong suat tin hieu tong for(j = 1 : Iteration)

H =(0.01)*(randn(nr_V,nt_V)+j*randn(nr_V,nt_V)); [S V D] = svd(H);

if (nt==1 && nr ~= 1) || (nt~=1 && nr ==1) landas(:,j)=V(1,1);

else

landas(:,j) = diag(V); % landas la can bac hai khong am cua gia


end

tri rieng cua H end

[Capacity(i,j) PowerAllo] = WaterFilling_alg(Pt,landas(:,j),N0);

c=mean(Capacity')

end


end

f1 = figure(1); hold on

plot(SNR_V_db,mean(Capacity'),notation(k,:),'color',color(k,:)) clear landas;

legend_str = [];

for( i = 1 : length(nt_V))

legend_str =[ legend_str ;...

{['nt = ',num2str(nt_V(i)),' , nr = ',num2str(nr_V(i))]}];

end legend(legend_str) grid on set(f1,'color',[1 1 1]) xlabel('SNR in dB')

ylabel('Capacity bits/s/Hz')

Function [Capacity PowerAllo] = WaterFilling_alg(PtotA,ChA,N0)

Xem toàn bộ nội dung bài viết ᛨ

..... Xem trang tiếp theo?
⇦ Trang trước - Trang tiếp theo ⇨

Ngày đăng: 23/05/2023