MATLAB code to decode all the received words for (n,k) linear block code.

Code: clc; clear all; close all; n=input('enter the code digits'); k=input('enter the data digits'); p=input('enter the parity matrix it must bei k rows and m coloums'); disp(p) z=input('enter 1 for systmetic and 0 for nonsystmetic'); msg=[]; for i=0:2^k-1     msg=[msg;de2bi(i,k,'left-msb')]; end if z==1   %p=[1 0 1;0 1 1;1 1 0];   i=eye([k k])   g=[i p] else   g=input('enter the generator matrix in k*n ');  end    code =rem(msg*g,2) decmsg=decode(code ,n,k,'l...

Matlab Code to Find syndrome for each possible error vector & prepare a suitable decoding table for (n,k) systematic linear block code.

Code: clc; clear all; close all; n=input('enter the code digits'); k=input('enter the data digits'); i=eye([k k]) d = de2bi(0:2^k-1,3,'left-msb'); a = input('to generate systematic code press 1 or any other to generate non systematic code:   '); if(a ==1 ) sprintf('enter parity matrix of size %dX%d',k,n-k) p =input('parity matrix:   '); g=[i p]; h=[p i]; c=rem(d*g,2) else sprintf('enter generator matrix of size %dX%d',k,n)  ns = input('generator matrix:  '); c1=rem(d*ns,2) h=ns; end...

Code to Determine all the codewords and minimum weights of (n,k) linear block code in matlab

Code: clc; clear all; close all; n=input('enter the code digits'); k=input('enter the data digits'); p=input('enter the parity matrix it must bei k rows and m coloums'); disp(p) z=input('enter 1 for systmetic and 0 for nonsystmetic'); msg=[]; for i=0:2^k-1     msg=[msg;de2bi(i,k,'left-msb')]; end if z==1   %p=[1 0 1;0 1 1;1 1 0];   i=eye([k k])   g=[i p] else   g=input('enter the generator matrix in k*n ');  end    code =rem(msg*g,2)...

Code to Determine the error correcting capability of given (n,k) code using hamming bound in matlab

Code: clc; clear all; close all; n=input('enter the code bits : n :'); k=input('enter the data bits : k :'); m=n-k; disp(m); z=2^m; disp (z); i=0; for j=0:1:n     sum=0;     for i=0:1:j            c=factorial(n)/(factorial(n-i)*factorial(i));            sum=sum+c;     end     if   sum >=z         j=j-1;        ...

Code to Find entropy for the given set of probability using MATLAB

Code: n=input('How many messages are there? : '); p=[ ]; for x= 1:n     sprintf('Enter the value of the message %d ''s probability',x)     p(x)=input('p = '); end entr=0; if sum(p)==1     for x=1:n         entr=entr+p(x)*log(1/p(x));     end else...

Matlab code for Computation of Linear convolution with DFT

Code: clc; clear all; g=input('Type in the first sequence:'); h=input('Type in the second sequence:'); ga=[g zeros(1,length(h)-1)]; ha=[h zeros(1,length(g)-1)]; G=fft(ga); H=fft(ha); Y=G.*H; y=ifft(Y); subplot 411; stem(g); title('First sequence'); subplot 412; stem(h); title('second sequence'); subplot 413; stem(y); title('New sequence'); subplot 414; plot(y); title('New sequence'); &nb...

Matlab code for Signal smoothing by moving- average Filter

Code: clc clear all; w=input('Enter window size:'); fs=input('Enter sampling freq:'); f=input('Enter freq:'); t=0:1/fs:1; x=sin(2*pi*f*t); e=0.5*randn(1,fs+1); xe=x+e; for n=1:fs-w     xblk=xe(1,n:n+w-1);     y(n)=(1/w)*sum(xblk); end...

Generate the Complex exponential sequence with MATLAB

Code: Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 clc; clear all; a=input('Type in real exponent : '); b=input('Type in complex exponent : '); c=a+b*i; k=input('Type in the gain constant : '); N=input('Type in length of sequence : '); n=1:N; x=k*exp(c*n); subplot(2,1,1) stem(n-1,real(x)); xlabel('time...