Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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];
- z=1; %starting value for z
- y=1; %starting value for y
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
- if J(1,i)==77
- a=J(1, 1:5);
- end
- end
- 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
- if J(2,i)==77
- b=J(2, 1:5);
- end
- end
- 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
- if J(3,i)==77
- c=J(3, 1:5);
- end
- end
- 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
- if J(4,i)==77
- d=J(4, 1:5);
- end
- end
- 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
- if J(5,i)==77
- e=J(5, 1:5);
- end
- end
- 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
- if J(6,i)==77
- f=J(6, 1:5);
- end
- end
- K=[a ;b ;c ;d ;e ;f]; %create matrix K with variables a b c d e and f
- if a~=[0 0 0 0 0]% if "a" does not equal 00000 then add 1 to "z"
- z=z+1;
- end
- if a==[0 0 0 0 0]% if "a" does equal 00000 then delete the zth row of the matrix k
- K(z,:)=[]
- end
- if b~=[0 0 0 0 0]% if "b" does not equal 00000 then add 1 to "z"
- z=z+1;
- end
- if b==[0 0 0 0 0]% if "b" does equal 00000 then delete the zth row of the matrix k
- K(z,:)=[]
- end
- if c~=[0 0 0 0 0]% if "c" does not equal 00000 then add 1 to "z"
- z=z+1;
- end
- if c==[0 0 0 0 0]% if "c" does equal 00000 then delete the zth row of the matrix k
- K(z,:)=[]
- end
- if d~=[0 0 0 0 0]% if "d" does not equal 00000 then add 1 to "z"
- z=z+1;
- end
- if d==[0 0 0 0 0]% if "d" does equal 00000 then delete the zth row of the matrix k
- K(z,:)=[]
- end
- if e~=[0 0 0 0 0]% if "e" does not equal 00000 then add 1 to "z"
- z=z+1;
- end
- if e==[0 0 0 0 0]% if "e" does equal 00000 then delete the zth row of the matrix k
- K(z,:)=[]
- end
- if f~=[0 0 0 0 0]% if "f" does not equal 00000 then add 1 to "z"
- z=z+1;
- end
- if f==[0 0 0 0 0]% if "f" does equal 00000 then delete the zth row of the matrix k
- K(z,:)=[]
- end
- if a==[0 0 0 0 0]% if "a" does =00000 (did not contain 77) then variable "o" equals row 1 of matrix J
- o=J(1, 1:5);
- end
- if b==[0 0 0 0 0]% if "b" does =00000 (did not contain 77) then variable "p" equals row 1 of matrix J
- p=J(2, 1:5);
- end
- if c==[0 0 0 0 0]% if "c" does =00000 (did not contain 77) then variable "q" equals row 1 of matrix J
- q=J(3, 1:5);
- end
- if d==[0 0 0 0 0]% if "d" does =00000 (did not contain 77) then variable "r" equals row 1 of matrix J
- r=J(4, 1:5);
- end
- if e==[0 0 0 0 0]% if "e" does =00000 (did not contain 77) then variable "s" equals row 1 of matrix J
- s=J(5, 1:5);
- end
- if f==[0 0 0 0 0]% if "f" does =00000 (did not contain 77) then variable "t" equals row 1 of matrix J
- t=J(6, 1:5);
- end
- 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.
- if o~=[0 0 0 0 0] %if "o" does not equal 00000 the add 1 to "y"
- y=y+1;
- end
- if o==[0 0 0 0 0]% if "o" does equal 00000 then delete the yth row of Matrix L
- L(y,:)=[]
- end
- if p~=[0 0 0 0 0]%if "p" does not equal 00000 the add 1 to "y"
- y=y+1;
- end
- if p==[0 0 0 0 0]% if "p" does equal 00000 then delete the yth row of Matrix L
- L(y,:)=[]
- end
- if q~=[0 0 0 0 0]%if "q" does not equal 00000 the add 1 to "y"
- y=y+1;
- end
- if q==[0 0 0 0 0]% if "q" does equal 00000 then delete the yth row of Matrix L
- L(y,:)=[]
- end
- if r~=[0 0 0 0 0]%if "r" does not equal 00000 the add 1 to "y"
- y=y+1;
- end
- if r==[0 0 0 0 0]% if "r" does equal 00000 then delete the yth row of Matrix L
- L(y,:)=[]
- end
- if s~=[0 0 0 0 0]%if "s" does not equal 00000 the add 1 to "y"
- y=y+1;
- end
- if s==[0 0 0 0 0]% if "s" does equal 00000 then delete the yth row of Matrix L
- L(y,:)=[]
- end
- if t~=[0 0 0 0 0]%if "t" does not equal 00000 the add 1 to "y"
- y=y+1;
- end
- if t==[0 0 0 0 0]% if "t" does equal 00000 then delete the yth row of Matrix L
- L(y,:)=[]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement