SHARE
TWEET

Untitled

a guest Nov 14th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %% MARQUEZ, FRANCIS RYAN
  2. % ECE 141 - PROBSET 2 - ITEM 2
  3.  
  4. %% solution 1 (bad solution)
  5.  
  6. clear all
  7. clc
  8.  
  9. % c = mG
  10. n = 11;
  11. msg = flip(dec2bin(2^n-1:-1:0)-'0');
  12. size(msg);
  13.  
  14. g1 = [1 0 0 0 0 0 0 0 0 0 0 0 0 0 1];
  15. g2 = [0 1 0 0 0 0 0 0 0 0 0 1 0 1 0];
  16. g3 = [0 0 1 0 0 0 0 0 0 0 0 0 1 0 1];
  17. g4 = [0 0 0 1 0 0 0 0 0 0 0 1 1 0 1];
  18. g5 = [0 0 0 0 1 0 0 0 0 0 0 0 0 1 1];
  19. g6 = [0 0 0 0 0 1 0 0 0 0 0 0 1 1 0];
  20. g7 = [0 0 0 0 0 0 1 0 0 0 0 1 1 0 0];
  21. g8 = [0 0 0 0 0 0 0 1 0 0 0 0 1 1 1];
  22. g9 = [0 0 0 0 0 0 0 0 1 0 0 1 1 1 0];
  23. g10 = [0 0 0 0 0 0 0 0 0 1 0 1 1 1 1];
  24. g11 = [0 0 0 0 0 0 0 0 0 0 1 1 0 1 1];
  25.  
  26. g = [g1;g2;g3;g4;g5;g6;g7;g8;g9;g10;g11];
  27. size(g);
  28.  
  29. c = gf(msg)*gf(g);
  30.  
  31. c1 = [1 0 0 0 0 0 0 0 0 0 0 1 0 0 1];
  32. c2 = [1 0 1 0 0 0 0 0 0 0 0 0 1 0 1];
  33. c3 = [1 0 0 0 0 0 0 0 0 1 1 1 1 0 1];
  34. c4 = [1 0 0 0 1 1 1 0 0 0 0 1 1 1 1];
  35.  
  36. disp('test for c1')
  37. ismember(c1,c,'rows')
  38.  
  39. disp('test for c2')
  40. ismember(c2,c,'rows')
  41.  
  42. disp('test for c3')
  43. ismember(c3,c,'rows')
  44.  
  45. disp('test for c4')
  46. ismember(c4,c,'rows')
  47.  
  48. %% solution 2 (best solution)
  49.  
  50. clear all
  51. clc
  52.  
  53. h1 = [0 1 0 1 0 0 1 0 1 1 1 1 0 0 0];
  54. h2 = [0 0 1 1 0 1 1 1 1 1 0 0 1 0 0];
  55. h3 = [0 1 0 0 1 1 0 1 1 1 1 0 0 1 0];
  56. h4 = [1 0 1 1 1 0 0 1 0 1 1 0 0 0 1];
  57. ht = [h1;h2;h3;h4]';
  58.  
  59. c1 = [1 0 0 0 0 0 0 0 0 0 0 1 0 0 1];
  60. c2 = [1 0 1 0 0 0 0 0 0 0 0 0 1 0 1];
  61. c3 = [1 0 0 0 0 0 0 0 0 1 1 1 1 0 1];
  62. c4 = [1 0 0 0 1 1 1 0 0 0 0 1 1 1 1];
  63. c = [c1;c2;c3;c4];
  64.  
  65. c = gf(c)*gf(ht)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top