Advertisement
Guest User

MATLAB code

a guest
Sep 21st, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 5.42 KB | None | 0 0
  1. J=[1 2 3 77 5; 77 1 2 77 3 ;1 2 3 4 5 ;1 2 3 4 5 ;1 77 3 4 5 ;1 2 3 4 5];
  2. z=1; %starting value for z
  3. y=1; %starting value for y
  4.  
  5. a=[0 0 0 0 0];%Making each row on matrix K equal to 00000, a is the value of row 1 on matrix K.
  6. b=[0 0 0 0 0];%Making each row on matrix K equal to 00000, b is the value of row 1 on matrix K.
  7. c=[0 0 0 0 0];%Making each row on matrix K equal to 00000, c is the value of row 1 on matrix K.
  8. d=[0 0 0 0 0];%Making each row on matrix K equal to 00000, d is the value of row 1 on matrix K.
  9. e=[0 0 0 0 0];%Making each row on matrix K equal to 00000, e is the value of row 1 on matrix K.
  10. f=[0 0 0 0 0];%Making each row on matrix K equal to 00000, f is the value of row 1 on matrix K.
  11. o=[0 0 0 0 0];%Making each row on matrix L equal to 00000, o is the value of row 1 on matrix L.
  12. p=[0 0 0 0 0];%Making each row on matrix L equal to 00000, p is the value of row 1 on matrix L.
  13. q=[0 0 0 0 0];%Making each row on matrix L equal to 00000, q is the value of row 1 on matrix L.
  14. r=[0 0 0 0 0];%Making each row on matrix L equal to 00000, r is the value of row 1 on matrix L.
  15. s=[0 0 0 0 0];%Making each row on matrix L equal to 00000, s is the value of row 1 on matrix L.
  16. t=[0 0 0 0 0];%Making each row on matrix L equal to 00000, t is the value of row 1 on matrix L.
  17.  
  18.  
  19. for i=1:length(J(1,:))% If row 1 of matrix J has 77 in any position set varible "a" equal to row 1 of matrix J
  20.     if J(1,i)==77
  21.   a=J(1, 1:5);
  22.     end
  23. end
  24. for i=1:length(J(1,:))% If row 2 of matrix J has 77 in any position set varible "b" equal to row 2 of matrix J
  25.     if J(2,i)==77
  26.     b=J(2, 1:5);
  27.     end
  28.  
  29. end
  30. for i=1:length(J(1,:))% If row 2 of matrix J has 77 in any position set varible "c" equal to row 3 of matrix J
  31.     if J(3,i)==77
  32.     c=J(3, 1:5);
  33.    
  34.     end
  35.  
  36. end
  37. for i=1:length(J(1,:))% If row 4 of matrix J has 77 in any position set varible "d" equal to row 4 of matrix J
  38.     if J(4,i)==77
  39.     d=J(4, 1:5);
  40.     end
  41.  
  42. end
  43. for i=1:length(J(1,:))% If row 5 of matrix J has 77 in any position set varible "e" equal to row 5 of matrix J
  44.     if J(5,i)==77
  45.     e=J(5, 1:5);
  46.     end
  47.  
  48. end
  49. for i=1:length(J(1,:))% If row 6 of matrix J has 77 in any position set varible "f" equal to row 6 of matrix J
  50.     if J(6,i)==77
  51.     f=J(6, 1:5);
  52.     end
  53.  
  54. end
  55.  
  56.  
  57. K=[a ;b ;c ;d ;e ;f]; %create matrix K with variables a b c d e and f
  58.  
  59. if a~=[0 0 0 0 0]% if "a" does not equal 00000 then add 1 to "z"
  60.     z=z+1;
  61. end
  62.  
  63. if a==[0 0 0 0 0]% if "a" does equal 00000 then delete the zth row of the matrix k
  64.    
  65.         K(z,:)=[]
  66. end
  67.  
  68. if b~=[0 0 0 0 0]% if "b" does not equal 00000 then add 1 to "z"
  69.     z=z+1;
  70. end
  71.  
  72. if b==[0 0 0 0 0]% if "b" does equal 00000 then delete the zth row of the matrix k
  73. K(z,:)=[]
  74. end
  75.  
  76. if c~=[0 0 0 0 0]% if "c" does not equal 00000 then add 1 to "z"
  77.     z=z+1;
  78. end
  79.  
  80. if c==[0 0 0 0 0]% if "c" does equal 00000 then delete the zth row of the matrix k
  81.    
  82. K(z,:)=[]
  83. end
  84.  
  85. if d~=[0 0 0 0 0]% if "d" does not equal 00000 then add 1 to "z"
  86.     z=z+1;
  87. end
  88. if d==[0 0 0 0 0]% if "d" does equal 00000 then delete the zth row of the matrix k
  89. K(z,:)=[]
  90. end
  91.  
  92. if e~=[0 0 0 0 0]% if "e" does not equal 00000 then add 1 to "z"
  93.     z=z+1;
  94. end
  95. if e==[0 0 0 0 0]% if "e" does equal 00000 then delete the zth row of the matrix k
  96. K(z,:)=[]
  97. end
  98. if f~=[0 0 0 0 0]% if "f" does not equal 00000 then add 1 to "z"
  99.     z=z+1;
  100. end
  101. if f==[0 0 0 0 0]% if "f" does equal 00000 then delete the zth row of the matrix k
  102. K(z,:)=[]
  103. end
  104.  
  105.  
  106.  
  107. if a==[0 0 0 0 0]% if "a" does =00000 (did not contain 77) then variable "o" equals row 1 of matrix J
  108.     o=J(1, 1:5);
  109. end
  110.    
  111. if b==[0 0 0 0 0]% if "b" does =00000 (did not contain 77) then variable "p" equals row 1 of matrix J
  112.     p=J(2, 1:5);
  113. end
  114.  if c==[0 0 0 0 0]% if "c" does =00000 (did not contain 77) then variable "q" equals row 1 of matrix J
  115.     q=J(3, 1:5);
  116.  end
  117.    
  118.  if d==[0 0 0 0 0]% if "d" does =00000 (did not contain 77) then variable "r" equals row 1 of matrix J
  119.     r=J(4, 1:5);
  120.  end
  121.    
  122.  if e==[0 0  0 0 0]% if "e" does =00000 (did not contain 77) then variable "s" equals row 1 of matrix J
  123.     s=J(5, 1:5);
  124.  end
  125.    
  126. if f==[0 0 0 0 0]% if "f" does =00000 (did not contain 77) then variable "t" equals row 1 of matrix J
  127.     t=J(6, 1:5);
  128. end
  129.    
  130.  
  131. L=[o ;p ;q ;r ;s ;t]; %create matrix L (matrix containing rows which did not include the number 77) using values for o p q r s t.
  132.  
  133.  
  134.  
  135. if o~=[0 0 0 0 0] %if "o" does not equal 00000 the add 1 to "y"
  136.     y=y+1;
  137. end
  138.  
  139. if o==[0 0 0 0 0]% if "o" does equal 00000 then delete the yth row of Matrix L
  140.     L(y,:)=[]
  141. end
  142.  
  143. if p~=[0 0 0 0 0]%if "p" does not equal 00000 the add 1 to "y"
  144.     y=y+1;
  145. end
  146.  
  147. if p==[0 0 0 0 0]% if "p" does equal 00000 then delete the yth row of Matrix L
  148.     L(y,:)=[]
  149. end
  150.  
  151. if q~=[0 0 0 0 0]%if "q" does not equal 00000 the add 1 to "y"
  152.     y=y+1;
  153. end
  154.  
  155. if q==[0 0 0 0 0]% if "q" does equal 00000 then delete the yth row of Matrix L
  156.     L(y,:)=[]
  157. end
  158.  
  159. if r~=[0 0 0 0 0]%if "r" does not equal 00000 the add 1 to "y"
  160.     y=y+1;
  161. end
  162.  
  163. if r==[0 0 0 0 0]% if "r" does equal 00000 then delete the yth row of Matrix L
  164.     L(y,:)=[]
  165. end
  166.  
  167. if s~=[0 0 0 0 0]%if "s" does not equal 00000 the add 1 to "y"
  168.     y=y+1;
  169. end
  170.  
  171. if s==[0 0 0 0 0]% if "s" does equal 00000 then delete the yth row of Matrix L
  172.     L(y,:)=[]
  173. end
  174.  
  175. if t~=[0 0 0 0 0]%if "t" does not equal 00000 the add 1 to "y"
  176.     y=y+1;
  177. end
  178.  
  179. if t==[0 0 0 0 0]% if "t" does equal 00000 then delete the yth row of Matrix L
  180.     L(y,:)=[]
  181. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement