Wednesday, 4 September 2013

Script for computing the BER for BPSK modulation in a Rayleigh fading channel with 2 Tx, 2Rx MIMO channel Zero Forcing equalization



% Script for computing the BER for BPSK modulation in a
% Rayleigh fading channel with 2 Tx, 2Rx MIMO channel
% Zero Forcing equalization

clear
N = 10^6; % number of bits or symbols
Eb_N0_dB = (0:25); % multiple Eb/N0 values
nTx = 2;
nRx = 2;
for ii = 1:length(Eb_N0_dB)

    % Transmitter
    ip = rand(1,N)>0.5; % generating 0,1 with equal probability
    s = 2*ip-1; % BPSK modulation 0 -> -1; 1 -> 0

    sMod = kron(s,ones(nRx,1)); %
    sMod = reshape(sMod,[nRx,nTx,N/nTx]); % grouping in [nRx,nTx,N/NTx ] matrix

    h = 1/sqrt(2)*(randn(nRx,nTx,N/nTx) + j*randn(nRx,nTx,N/nTx)); % Rayleigh channel
    n = 1/sqrt(2)*(randn(nRx,N/nTx) + j*randn(nRx,N/nTx)); % white gaussian noise, 0dB variance

    % Channel and noise Noise addition
    y = squeeze(sum(h.*sMod,2)) + 10^(-Eb_N0_dB(ii)/20)*n;

    % Receiver

    % Forming the Zero Forcing equalization matrix W = inv(H^H*H)*H^H
    % H^H*H is of dimension [nTx x nTx]. In this case [2 x 2]
    % Inverse of a [2x2] matrix [a b; c d] = 1/(ad-bc)[d -b;-c a]
    hCof = zeros(2,2,N/nTx)  ;
    hCof(1,1,:) = sum(h(:,2,:).*conj(h(:,2,:)),1);  % d term
    hCof(2,2,:) = sum(h(:,1,:).*conj(h(:,1,:)),1);  % a term
    hCof(2,1,:) = -sum(h(:,2,:).*conj(h(:,1,:)),1); % c term
    hCof(1,2,:) = -sum(h(:,1,:).*conj(h(:,2,:)),1); % b term
    hDen = ((hCof(1,1,:).*hCof(2,2,:)) - (hCof(1,2,:).*hCof(2,1,:))); % ad-bc term
    hDen = reshape(kron(reshape(hDen,1,N/nTx),ones(2,2)),2,2,N/nTx);  % formatting for division
    hInv = hCof./hDen; % inv(H^H*H)

    hMod =  reshape(conj(h),nRx,N); % H^H operation
   
    yMod = kron(y,ones(1,2)); % formatting the received symbol for equalization
    yMod = sum(hMod.*yMod,1); % H^H * y
    yMod =  kron(reshape(yMod,2,N/nTx),ones(1,2)); % formatting
    yHat = sum(reshape(hInv,2,N).*yMod,1); % inv(H^H*H)*H^H*y
  
    % receiver - hard decision decoding
    ipHat = real(yHat)>0;

    % counting the errors
    nErr(ii) = size(find(ip- ipHat),2);

end

simBer = nErr/N; % simulated ber
EbN0Lin = 10.^(Eb_N0_dB/10);
theoryBer_nRx1 = 0.5.*(1-1*(1+1./EbN0Lin).^(-0.5));
p = 1/2 - 1/2*(1+1./EbN0Lin).^(-1/2);
theoryBerMRC_nRx2 = p.^2.*(1+2*(1-p));

close all
figure
semilogy(Eb_N0_dB,theoryBer_nRx1,'bp-','LineWidth',2);
hold on
semilogy(Eb_N0_dB,theoryBerMRC_nRx2,'kd-','LineWidth',2);
semilogy(Eb_N0_dB,simBer,'mo-','LineWidth',2);
axis([0 25 10^-5 0.5])
grid on
legend('theory (nTx=1,nRx=1)', 'theory (nTx=1,nRx=2, MRC)', 'sim (nTx=2, nRx=2, ZF)');
xlabel('Average Eb/No,dB');
ylabel('Bit Error Rate');
title('BER for BPSK modulation with 2x2 MIMO and ZF equalizer (Rayleigh channel)');



NIKOLA TESLA -genius who lit the world



THE FORGOTTEN GENIUS:
Nikola Tesla symbolizes a unifying force and inspiration for all nations in the name of peace and science. He was a true visionary far ahead of his contemporaries in the field of scientific development. 

Tesla's first breakthrough came as rotating magnetic field that would allow alternating current to power an engine without being first converted to direct current.

Nikola Tesla developed polyphase alternating current system of generators, motors and transformers. Which is today lighting the entire globe.

Tesla’s   alternating current induction motor is considered one of the ten greatest discoveries of all time. The Tesla coil, which he invented in 1891, is widely used today in radio and television sets 


Among his discoveries are the fluorescent light, laser beam, wireless communications, and wireless transmission of electrical energy, remote control, robotics, Tesla’s turbines and vertical takeoff aircraft. Tesla is the father of the radio and the modern electrical transmissions systems He is the first scientist in the world to use the Ionosphere for scientific purposes. He registered over 700 patents worldwide.
  Tesla discovered X-Rays and made one of the first man made x-ray photographs way before Roentgen published his discovery of x-rays.   

Tesla's electro-mechanical oscillator is a steam-powered electric generator that could simulate earthquakes. Tesla claimed to have invented a death ray which he called Teleforce that could focus intense beam of particles that could destroy a target at a distance up to 4 miles.

It is Tesla's original concept demonstrated the four tuned circuits for transmitting and receiving.  The four   circuits, used in two pairs, are still a fundamental part of all radio and television equipment.

Tesla made what he regarded as his most important discovery-- terrestrial stationary waves.  By this discovery he proved that the Earth could be used as a conductor and would be as responsive as a tuning fork to electrical vibrations of a certain frequency.  He also lighted 200 lamps without wires from a distance of 25 miles (40 kilometers) and created man-made lighting.

On his final days lying in the forgotten hotel alone and penny less Tesla, “Let the future tell the truth, and evaluate each one according to his work and accomplishments. The present is theirs. The future, for which I have really worked, is mine"


The United States Supreme Court, in 1943 held Marconi's most important patent invalid, recognizing Tesla's more significant contribution as the inventor of radio technology.


On his honor, The Nikola Tesla Award one of the most distinguished honors presented by the Institute of Electrical Engineers (IEEE) for significant contributions in the field of electricity.  The award has been given annually since 1976.