views:

27

answers:

1

Heia...

I'm trying to write the code QPSK with zeroforcing when N=2 and i got one error which i dont know how to fix it. plz help me. thanks alot

here is the code:

Modulation = 'QPSK'
Decode_Method = 'ZeroForcing'
switch Modulation
    case {'QPSK'}
        Symbols = [ 1+j 1-j -1+j -1-j ]';
end
Symbols = Symbols.';
nSymbols = length(Symbols);

SNR_Array = [0.3 0.7 1.2 2.5 5 6.2 10 15.4 22 45 75.7 100.0];
nSNR = length(SNR_Array);

Ntest = 20;
N = 2;

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( nSymbols*rand(N,1) ) )';
        Noise = (randn(N,1) + j*randn(N,1))/sqrt(2)/sqrt(SNR);
        Y = H*X + Noise;
        switch Decode_Method
            case {'ZeroForcing'}
                X_Decode = Zero_Forcing(Y,H,Symbols);
        end
    end
    Nerror = Nerror + length( find( X ~= X_Decode) );
end
Symbol_Error_Rate(iSNR) = Nerror/Ntest/N;

figure(1)
loglog(SNR_Array, Symbol_Error_Rate,'b')
hold on
xlabel('SNR')
ylabel('Symbol Error Ratio')
title('Symbol Error Ratio for NxN MIMO System')

and the error is:

??? Undefined function or method 'Zero_Forcing' for input arguments of type 'double'.
Error in ==> Untitled2 at 33 
X_Decode = Zero_Forcing(Y,H,Symbols);
A: 

The error indicates that Matlab cannot find the function Zero_Forcing. If you have a function of that name, you should make sure it's on the Matlab path, i.e. a directory Matlab knows about. Otherwise, you should write the function. It seems rather important.

Also, you may want to not call your function 'Untitled2', but give it a more meaningful name.

Jonas