Filter löschen
Filter löschen

continue entering statement in command window

3 Ansichten (letzte 30 Tage)
Kartickeyan V
Kartickeyan V am 29 Jan. 2017
Kommentiert: Jan am 29 Jan. 2017
*When i tried to run this program i am getting a line as continue entering statement in command window and not getting output *
% BER Vs SNR FOR OSTBC OVER RAYLEIGH CHANNEL WITH BPSK MODULATION
%%Simulation parameters
M = 1 ; frLen = 50; numPackets = 1000; EbNo = 0:2:20;
N = 2; % Number of transmit antennas
rate = 1; inc = N/rate; repFactor = 2;
% Create BPSK mod-demod objects
P = 2; % modulation order
bpskmod = modem.pskmod('M', P, 'SymbolOrder', 'Gray', 'InputType', 'Integer');
bpskdemod = modem.pskdemod(bpskmod);
%%Pre-allocate variables for speed
txEnc = zeros(frLen/rate, N); r = zeros(frLen/rate, M);
H = zeros(frLen/rate, N, M);
z = zeros(frLen, M); z1 = zeros(frLen/N, M); z2 = z1;
error2m = zeros(1, numPackets); BER2m = zeros(1, length(EbNo));
%%Loop over EbNo points
for idx = 1:length(EbNo)
% Loop over the number of packets
for packetIdx = 1:numPackets
data = randint(frLen, 1, P); % data vector per user/channel
tx = modulate(bpskmod, data); % BPSK modulation
% Alamouti Space-Time Block Encoder, G2, full rate
% G2 = [s1 s2; -s2* s1*]
s1 = tx(1:N:end); s2 = tx(2:N:end);
txEnc(1:inc:end, :) = [s1 s2];
txEnc(2:inc:end, :) = [-conj(s2) conj(s1)];
% Create the Rayleigh channel response matrix
H(1:inc:end, :, :) = (randn(frLen/rate/repFactor, N, M) + ...
j*randn(frLen/rate/repFactor, N, M))/sqrt(2);
% held constant for repFactor symbol periods
H(2:inc:end, :, :) = H(1:inc:end, :, :);
% Received signal for each Rx antenna
for i = 1:M
% with power normalization
r(:, i) = awgn(sum(H(:, :, i).*txEnc, 2)/sqrt(N), EbNo(idx));
end
% Combiner - assume channel response known at Rx
hidx = 1:inc:length(H);
for i = 1:M
z1(:, i) = r(1:inc:end, i).* conj(H(hidx, 1, i)) + ...
conj(r(2:inc:end, i)).* H(hidx, 2, i);
z2(:, i) = r(1:inc:end, i).* conj(H(hidx, 2, i)) - ...
conj(r(2:inc:end, i)).* H(hidx, 1, i);
end
z(1:N:end, :) = z1; z(2:N:end, :) = z2;
% ML Detector (minimum Euclidean distance)
demod2m = demodulate(bpskdemod, sum(z, 2));
% Determine bit errors
error2m(packetIdx) = biterr(demod2m, data);
end % end of FOR loop for numPackets
% Calculate BER for current idx
BER2m1(idx) = sum(error2m)/(numPackets*frLen);
end % end of for loop for EbNo
figure(2);
semilogy(EbNo, BER2m1,'rd-','Linewidth',1.5);
axis([2 12 10^-4 10^0]);
grid on;
mode = 1;
global m Mt hmodem bit_T
m = 2;
Mt = 4;
Mr = 4;
bit_SMsym = log2(m*Mt); % number of bit per sysmbol
Nbits = bit_SMsym*1e4; % Number of bits to be simulated.
hmodem = modem.pskmod('M',m, 'SymbolOrder', 'Gray','InputType', 'bit');
hdemodem = modem.pskdemod('M', m,'SymbolOrder','Gray','OutputType','bit');
Eac = (mean(hmodem.Constellation .* conj(hmodem.Constellation)));
SNR = 0 : 2 :20; % signal-to-noise ratio in dB
No1= (Eac)*10.^(-SNR/10); % noise variance
L_SNR=length(SNR);
ber= zeros (L_SNR,1);
bit_R=zeros(Nbits, 1);
bit_T = randi([0 1],Nbits,1);
[mod_T ante]= SpatialMod();
mod_T = mod_T.';
for ii=1:L_SNR
for j = 1 : size(mod_T ,2)
channel = sqrt(.5)*( randn(Mr,Mt,1) + 1i*randn(Mr,Mt,1));
noise = sqrt(.5)*(randn(Mr , 1) + 1i*randn(Mr , 1))* sqrt(No1(ii));
p = diag(channel'*channel);
switch mode
case 1
y = channel(:,ante(j))*(mod_T(ante(j) ,j)./sqrt(p(ante(j)))) + noise;
z3 = (channel'*y)./p.^.5;
case 2
y = channel(:,ante(j)) * mod_T(ante(j) ,j) + noise ;
z3 = (channel'*y)./p;
end
[UnUsEdVaRiAbLe_To_IgNoRe, ant_est] = max(abs(z3));
bi_ant = de2bi(ant_est - 1 , log2(Mt) ,'left-msb');
bi_mod = demodulate(hdemodem, z3(ant_est,1) );
bit_R( (j-1)*bit_SMsym+1 : (j-1)*bit_SMsym+bit_SMsym,1) = [bi_ant.' ; bi_mod];
end
[UnUsEdVaRiAbLe_To_IgNoRe,ber(ii,1)] = biterr(bit_T(:,1),bit_R(:));
end
figure(1);
semilogy(SNR,ber(:,1),'color',[0,0.75,0.75],'linestyle','--','LineWidth',2.4);
axis([2 12 10^-3 10^0]);
xlabel('SNR');
ylabel('BER');
legend('MRT over Rayleigh');
title('BER performance of MRT');
grid on;
  1 Kommentar
Jan
Jan am 29 Jan. 2017
Please explain the details: When do you see exactly what? What does "a line as continue entering statement" mean? Do you copy this to the command window or is this copied from an M-script file?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by