It shows File: mainvala.m Line: 77 Column: 21 Invalid use of operator. whenever i run this. Any fixexs?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
%AMAN JAIN
%Ritwik Singh
%Arvindra kant nagar
clear
N = 10^6; % number of bits or symbols
EbN0dB = [0:25]; % multiple Eb/N0 values
nSym=128;
Tx = 2;
Rx = 2;
for ii = 1:length(EbN0dB)
% Transmitter
ip = rand(1,nSym)>0.5; % generating 0,1 with equal probability
s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 0
sMod = kron(s,ones(Rx,1)); %
sMod = reshape(sMod,[Rx,Tx,N/Tx]); % grouping in [nRx,nTx,N/NTx ] matrix
h = 1/sqrt(2)*[randn(Rx,Tx,N/Tx) + j*randn(Rx,Tx,N/Tx)]; % Rayleigh fading
n = 1/sqrt(2)*[randn(Rx,N/Tx) + j*randn(Rx,N/Tx)]; % white gaussian noise, 0dB variance
% Channel and noise Noise addition
y = squeeze(sum(h.*sMod,2)) + 10^(-EbN0dB(ii)/20)*n; %adding channel trhrough which signal wil pass
% Maximum Likelihood Receiver
% ----------------------------
% if [s1 s2 ] = [+1,+1 ]
sout1 = [1 1];
sout1 = repmat(sout1,[1 ,N/2]);
sout1Mod = kron(sout1,ones(Rx,1));
sout1Mod = reshape(sout1Mod,[Rx,Tx,N/Tx]);
zsout1 = squeeze(sum(h.*sout1Mod,2)) ;
J11 = sum(abs(y - zsout1),1);
% if [s1 s2 ] = [+1,-1 ]
sout2 = [1 -1];
sout2 = repmat(sout2,[1 ,N/2]);
sout2Mod = kron(sout2,ones(Rx,1));
sout2Mod = reshape(sout2Mod,[Rx,Tx,N/Tx]);
zsout2 = squeeze(sum(h.*sout2Mod,2)) ;
J10 = sum(abs(y - zsout2),1);
% if [s1 s2 ] = [-1,+1 ]
sout3 = [-1 1];
sout3 = repmat(sout3,[1 ,N/2]);
sout3Mod = kron(sout3,ones(Rx,1));
sout3Mod = reshape(sout3Mod,[Rx,Tx,N/Tx]);
zsout3 = squeeze(sum(h.*sout3Mod,2)) ;
J01 = sum(abs(y - zsout3),1);
% if [s1 s2 ] = [-1,-1 ]
sout4 = [-1 -1];
sout4 = repmat(sout4,[1 ,N/2]);
sout4Mod = kron(sout4,ones(Rx,1));
sout4Mod = reshape(sout4Mod,[Rx,Tx,N/Tx]);
zsout4 = squeeze(sum(h.*sout4Mod,2)) ;
J00 = sum(abs(y - zsout4),1);
% finding the minimum from the four combinations
rVec = [J11;J10;J01;J00];
[jj dd] = min(rVec,[],1);
% mapping the minima to bits
ref = [1 1; 1 0; 0 1; 0 0 ];
ipHat = zeros(1,N);
ipHat(1:2:end) = ref(dd,1);
ipHat(2:2:end) = ref(dd,2);
% counting the errors
nErr(ii) = size(find([ip- ipHat]),2);
end
%end
%end
simBer = nErr/N; % simulated ber
EbN0Lin = 10.^(EbN0dB/10);
theoryBer_nRx1 = 0.5.(1-1(1+1./EbN0Lin).^(-0.5));
p = 1/2 - 1/2.(1+1./EbN0Lin).^(-1/2);
theoryBerMRC_Rx2 = p.^2.(1+2(1-p));
close all
figure
semilogy(EbN0dB,theoryBer_nRx1,'g-O','LineWidth',2);
hold on
semilogy(EbN0dB,theoryBerMRC_Rx2,'kd-','LineWidth',2);
semilogy(EbN0dB,simBer,'--or','LineWidth',2);
axis([0 25 10^-5 0.5])
grid on
legend('theory (Tx=1,Rx=1)', 'theory (Tx=1,Rx=2, MRC)', 'sim (Tx=2, Rx=2, ML)');
xlabel('Average Eb/No,dB');
ylabel('Bit Error Rate');
title('BER VS SNR for 2x2 MIMO-OFDM-IM (Rayleigh channel)');
0 comentarios
Respuestas (1)
Steven Lord
el 9 de Dic. de 2021
Assuming the comment that starts your code is on line 1, lines 77-79 are:
theoryBer_nRx1 = 0.5.(1-1(1+1./EbN0Lin).^(-0.5));
p = 1/2 - 1/2.(1+1./EbN0Lin).^(-1/2);
theoryBerMRC_Rx2 = p.^2.(1+2(1-p));
You're missing operators after the first 0.5 on line 77, after the second 1/2 on line 78, and after both 2's on line 79.
0 comentarios
Ver también
Categorías
Más información sobre Propagation and Channel Models en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!