Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% MARQUEZ, FRANCIS RYAN
- % ECE 141 - PROBSET 2 - ITEM 2
- %% solution 1 (bad solution)
- clear all
- clc
- % c = mG
- n = 11;
- msg = flip(dec2bin(2^n-1:-1:0)-'0');
- size(msg);
- g1 = [1 0 0 0 0 0 0 0 0 0 0 0 0 0 1];
- g2 = [0 1 0 0 0 0 0 0 0 0 0 1 0 1 0];
- g3 = [0 0 1 0 0 0 0 0 0 0 0 0 1 0 1];
- g4 = [0 0 0 1 0 0 0 0 0 0 0 1 1 0 1];
- g5 = [0 0 0 0 1 0 0 0 0 0 0 0 0 1 1];
- g6 = [0 0 0 0 0 1 0 0 0 0 0 0 1 1 0];
- g7 = [0 0 0 0 0 0 1 0 0 0 0 1 1 0 0];
- g8 = [0 0 0 0 0 0 0 1 0 0 0 0 1 1 1];
- g9 = [0 0 0 0 0 0 0 0 1 0 0 1 1 1 0];
- g10 = [0 0 0 0 0 0 0 0 0 1 0 1 1 1 1];
- g11 = [0 0 0 0 0 0 0 0 0 0 1 1 0 1 1];
- g = [g1;g2;g3;g4;g5;g6;g7;g8;g9;g10;g11];
- size(g);
- c = gf(msg)*gf(g);
- c1 = [1 0 0 0 0 0 0 0 0 0 0 1 0 0 1];
- c2 = [1 0 1 0 0 0 0 0 0 0 0 0 1 0 1];
- c3 = [1 0 0 0 0 0 0 0 0 1 1 1 1 0 1];
- c4 = [1 0 0 0 1 1 1 0 0 0 0 1 1 1 1];
- disp('test for c1')
- ismember(c1,c,'rows')
- disp('test for c2')
- ismember(c2,c,'rows')
- disp('test for c3')
- ismember(c3,c,'rows')
- disp('test for c4')
- ismember(c4,c,'rows')
- %% solution 2 (best solution)
- clear all
- clc
- h1 = [0 1 0 1 0 0 1 0 1 1 1 1 0 0 0];
- h2 = [0 0 1 1 0 1 1 1 1 1 0 0 1 0 0];
- h3 = [0 1 0 0 1 1 0 1 1 1 1 0 0 1 0];
- h4 = [1 0 1 1 1 0 0 1 0 1 1 0 0 0 1];
- ht = [h1;h2;h3;h4]';
- c1 = [1 0 0 0 0 0 0 0 0 0 0 1 0 0 1];
- c2 = [1 0 1 0 0 0 0 0 0 0 0 0 1 0 1];
- c3 = [1 0 0 0 0 0 0 0 0 1 1 1 1 0 1];
- c4 = [1 0 0 0 1 1 1 0 0 0 0 1 1 1 1];
- c = [c1;c2;c3;c4];
- c = gf(c)*gf(ht)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement