-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcycliccode.sce
More file actions
29 lines (26 loc) · 864 Bytes
/
cycliccode.sce
File metadata and controls
29 lines (26 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
clc;
//Taking the generator polynomial as input
D=poly(0,'D');
disp('Enter the generator polynomial in variable D:');
p=input("",'string');
Gen_polynomial=evstr(p);
disp(Gen_polynomial, 'G(D)=');
//Taking code word length and length of message sequence as input
disp('Enter the length of the message sequence:');
k=input("");disp(k, 'k=');
disp('Enter the length of the codeword:');
n=input("");
disp(n, 'n=');
//Taking the message polynomial as input
disp('Enter the message polynomial in variable D:');
s=input("",'string');
message_poly=evstr(s);
disp(message_poly, 'm(D)=');
multiplier=D^(n-k);
y=multiplier*message_poly;
disp(y, 'Multiplied part:');
//Obtaining the remainder
[remainder,quotient]=pdiv(y,Gen_polynomial);
disp(remainder, 'b(D)');
codeword_poly=remainder+y;
disp(codeword_poly, 'The codeword polynomial x(D):');