I want to create a logical function that returns true if all non-zero elements in Matrix Z^2 are accompanied by non-zero (true) elements at the same locations in Z.
Z = [1,0,1;1,1,1;1,0,1]
Z^2 = [2,0,2;3,1,3;2,0,2]
From this basic example, every non-zero element in Z^2 is accompanied by a non-zero in Z. Hence the function output would be TRUE.
function output = ABC(Z)
output = (Z(i,j) & Z^2(i,j) ~= 0) then TRUE
or something to that effect.