Search code examples
matlabcommunicationprobabilitytelecommunication

How can I construct a 4-ary symmetric communication channel in Matlab?


I need to construct a symmetric channel over the alphabet {0,1,2,3} similar to Matlab's Binary Symmetric Channel. I need the probability of transmission error to be p/3 and the probability of successful transmission to be (1-p) for 0

I have not been able to find a Matlab function that meets my requirements and I was hoping somebody would know how to go about setting this up manually?

Any help appreciated.


Solution

  • I think this does what you want:

    %// Data
    transmitted = [ 0 3 2 1 3 2 ]; %// sequence of transmitted symbols. Example data
    M = 4; %// alphabet size
    p = .3; %// symbol error probability
    
    %// Generate received sequeence
    n = numel(transmitted); %// sequence size
    received = transmitted; %// no errors for for now
    ind = rand(1,n)<=p; %// index of symbols with error
    changes = randi(M-1,1,nnz(ind)); %// changes to be applied for symbols with error
    received(ind) = mod(received(ind)+changes,M); %// apply changes