| Communications Toolbox | ![]() |
To test for nonzero values in a Galois vector, or in the columns of a Galois array that has more than one row, use the any or all function. These two functions behave just like the ordinary MATLAB functions any and all, except that they consider only the underlying array elements while ignoring information about which Galois field the elements are in. Examples are below.
m = 3; randels = gf(randint(6,1,2^m),m);
if all(randels) % If all elements are invertible
invels = randels .\ 1; % Compute inverses of elements.
else
disp('At least one element was not invertible.');
end
alph = gf(2,4);
poly = 1 + alph + alph^3;
if any(poly) % If poly contains a nonzero value
disp('alph is not a root of 1 + D + D^3.');
end
code = rsenc(gf([0:4;3:7],3),7,5); % Each row is a codeword.
if all(code,2) % Is each row entirely nonzero?
disp('Both codewords are entirely nonzero.');
else
disp('At least one codeword contains a zero.');
end
| Testing for Equality | Matrix Manipulation in Galois Fields | ![]() |
© 1994-2005 The MathWorks, Inc.