Need help in matlab code

Status
Not open for further replies.

honhungoc

Member level 1
Joined
Dec 29, 2006
Messages
38
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,543
I hv tried to correct some mistakes but i'm was not able to run this code
Pls help me
Thank u

pls substitue by : )

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mod16qam.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Y = mod16qam(X,Fd,Fs,Eb);
% 16-QAM modulation
%----------------------
% Y = mod16qam(X,Fd,Fs,Eb)
%
% X - data stream
% Fd - data sampling rate
% Fs - Modulation signal samling rate (Fs/Fd integer)
% Eb - Average bit energy
%
M = 16;
half_d = sqrt(sqrt(0.4*Eb));
Y = half_d*dmodce(X,Fd,Fs,'qask',M)'; % QAM modulation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% demod16qam.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Y,Eb] = demod16qam(R,Fd,Fs);
% 16-QAM modulation
%----------------------
% [Y,Eb] = demod16qam(R,Fd,Fs)
%
% R - received signal (row vector)
% Fd - data sampling rate
% Fs - Modulation signal samling rate (Fs/Fd integer)
% Y - Output signal
% Eb - Average energy per received symbol
M = 16;
n = size(R,2);
Es = sum(abs(R).^2)/n;
Eb = Es/4;
half_d = sqrt(0.4*Eb);
% scatterplot(ynoisy,5,0,'b.'); % scatter plot of signal+noise
Y = ddemodce(R/half_d,Fd,Fs,'qask',M); % demodulated signal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SISO.m
% Single Input Single Output 16-QAM Simulation
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear;
close all;
SignalEnergyMin = 2;
SignalEnergyMax = 42;
SignalEnergy_d = 1;
BlocksPerEnergy = 100;
BlockSize = 2^8;
SamplingRate = 6;
WGNPower = 1;
RayleighParam = .4;
Antennas = 2;
M=16;
for aa=1:Antennas
Gvec1 = randn(1,BlocksPerEnergy);
Gvec2 = randn(1,BlocksPerEnergy);
RayleighVec(aa, = sqrt((RayleighParam^2.*Gvec1.^2)+(RayleighParam^2.*Gvec2.^2));
end
RayleighVec(1, = ones(1,size(RayleighVec,2));
EnergiesdB = SignalEnergyMin:SignalEnergy_d:SignalEnergyMax;
Energies = 10.^(EnergiesdB./10);
for ee = 1:size(Energies,2)
for bb = 1:BlocksPerEnergy
A = randint(1,BlockSize,16); % Generate Data Stream
B = mod16qam (A,1,SamplingRate,Energies(ee))'; % 16-QAM Modulation
for aa=1:Antennas
disp(['Eb = ',int2str(Energies(ee)),'; Block ',int2str(bb),'; Antenna ',int2str(aa)]);
C(aa, = RayleighVec(aa,bb).*B; % Rayleigh fading
D(aa, = AWGN(C(aa,,WGNPower); % AWGN
[E(aa,,Eb(aa,bb)] = demod16qam (D(aa,,1,SamplingRate); % Demodulate
[TT,SER(aa,bb)] = symerr(A,E(aa,); % Measure BER per antenna
end
end
for aa=1:Antennas
ESER(aa,ee) = mean(SER(aa,,2);
end
end
Eaxis = 10*log10((SignalEnergyMin:SignalEnergy_d:SignalEnergyMax)./(WGNPower^2));
figure;
semilogy(EnergiesdB,ESER,'+');
title ('\fontsize{12}\bf16-QAM SISO Bit Error Rate in a slow flat Rayleigh AWGN Channel');
xlabel ('Eb/N_0'); ylabel ('SER');
legend('No fading','Rayleigh fading (r=0.24)');
%% EOF %% EOF %% EOF %% EOF %% EOF %% EOF %% EOF %% EOF %% EOF %% EOF
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…