Clear Filters
Clear Filters

How to convert scilab code into matlab?

50 views (last 30 days)
sudha
sudha on 21 Mar 2014
Commented: Walter Roberson on 7 May 2024
I have a code in Scilab. How to convert that code into Matlab?? Can anyone please tel me..
  2 Comments
PADMA PRIYA
PADMA PRIYA on 7 May 2024
clear ;
clc ;
k = 4; //message bits
n = 7; // block length
m = n-k; //Number o f p a r i t y b i t s
I = eye(k,k); // i d e n t i t y mat r ix
disp (I, ' identity matrix Ik ' )
P =[1,1,0;0,1,1;1,1,1;1,0,1]; // c o e f f i c i e n t mat r ix
disp (P, 'coefficient matrix P' )
G = [P I]; // generator matrix
disp (G, ' generator matrix G' )
H = [eye(k -1,k -1) P' ]; // parity check matrix
disp (H, ' parity check matrix H' )
//message bits
m =[0,0,0,0;0,0,0,1;0,0,1,0;0,0,1,1;0,1,0,0;0,1,0,1;0,1,1,0;0,1,1,1;];
C = m*G;
C = modulo (C ,2) ;
disp (C, 'Code words o f ( 7 , 4 ) Hamming code ' )
Walter Roberson
Walter Roberson on 7 May 2024
clear ;
clc ;
k = 4; %//message bits
n = 7; %// block length
m = n-k; %//Number o f p a r i t y b i t s
I = eye(k,k); %// i d e n t i t y mat r ix
disp (' identity matrix Ik ' )
identity matrix Ik
disp(I)
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
P =[1,1,0;0,1,1;1,1,1;1,0,1]; %// c o e f f i c i e n t mat r ix
disp ('coefficient matrix P' )
coefficient matrix P
disp ( P )
1 1 0 0 1 1 1 1 1 1 0 1
G = [P I]; %// generator matrix
disp (' generator matrix G' )
generator matrix G
disp ( G )
1 1 0 1 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 1 0 1 0 1 0 0 0 1
H = [eye(k -1,k -1) P' ]; %// parity check matrix
disp (' parity check matrix H' )
parity check matrix H
disp ( H )
1 0 0 1 0 1 1 0 1 0 1 1 1 0 0 0 1 0 1 1 1
%//message bits
m =[0,0,0,0;0,0,0,1;0,0,1,0;0,0,1,1;0,1,0,0;0,1,0,1;0,1,1,0;0,1,1,1;];
C = m*G;
C = mod (C ,2) ;
disp ( 'Code words o f ( 7 , 4 ) Hamming code ' )
Code words o f ( 7 , 4 ) Hamming code
disp ( C )
0 0 0 0 0 0 0 1 0 1 0 0 0 1 1 1 1 0 0 1 0 0 1 0 0 0 1 1 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 0 0 1 1 0 0 0 1 0 1 1 1

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 21 Mar 2014
Paste it into MATLAB and start changing it into MATLAB syntax.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!