views:

41

answers:

1

this code is work with 2x2 QPSK but not working with 3x3 QPSK of Maximum likelihood and dont know how to fix it

this is the code of 3x3 for Likelihood

function [Received_Symbols] = ML_Decode_3_3(Y,H,Symbols)

N=3;

nSymbols = length(Symbols);

Symbol_Vectors = [ kron( ones(1,nSymbols) , Symbols ) ; kron( Symbols , ones(1,nSymbols) ) ];

YMHS = kron(Y,ones(1,nSymbols^N)) - H*Symbol_Vectors;

Distance = sum( YMHS.*conj(YMHS) , 1 );

[ C , Index] = min(Distance);

Received_Symbols = Symbol_Vectors(:,Index);

and then adding the test code to it

Modulation = 'QPSK'

Decode_Method = 'Maximum Likelihood'

switch Modulation

case {'QPSK'}

Symbols = [ 1+j 1-j -1+j -1-j ]';

end

Symbols = Symbols.'

SNR_Array = [0.1 0.3 0.7 1.2 2.5 5 6.2 10 15.4 22 45 75.7 100 200];

nSNR = length(SNR_Array);

Ntest = 20;

N = 3;

for iSNR = 1 : nSNR

SNR = SNR_Array(iSNR);

Nerror = 0;

for i = 1:Ntest

H = randn(N,N) + j*randn(N,N);

X = Symbols( ceil( 4*rand(N,1) ) )';

Noise = (randn(N,1) + j*randn(N,1))/sqrt(2)/sqrt(SNR);

Y = H*X + Noise;

switch Decode_Method

case {'Maximum Likelihood'}

X_Decode = ML_Decode_3_3(Y,H,Symbols);

Nerror = Nerror + length( find( X ~= X_Decode) );

end

end

Symbol_Error_Rate(iSNR) = Nerror/Ntest/N;

end figure(1)

loglog(SNR_Array, Symbol_Error_Rate,'b')

xlabel('SNR')

ylabel('Symbol Error Ratio')

title('Symbol Error Ratio')

error is :

??? Error using ==> mtimes Inner matrix dimensions must agree

Error in ==> ML_3_3 at 11 YMHS = kron(Y,ones(1,nSymbols^N)) - H*Symbol_Vectors;

Error in ==> test_ML_3_3 a 36 X_Decode = ML_Decode_3_3(Y,H,Symbols);


thanks

+1  A: 

Without more specifics, it's hard to know what you want, but did you try searching for QAM on the FEX?

Richie Cotton
ok here is the code but cant write it all here because of the limited characters find it above plz i edited it thanks