It is possible to place a matrix valued function as the condition of a branching construction or while loop. However one must be careful! Consider the construction
if A~=B, program, end
You would like program to execute if the matrices A and B differ i some entry. Under the convention, program will only execute when they differ on all entries. There are some ways around this problem. One is the construction
if A==B, else program, end
which will pass control to the "else" part if A and B differ on at least one entry. Another solution is to convert A==B into a binary valued functionm by using all(all(A==B)). The inside all creates a binary vector whose ith entry is 1 only if the ith column of A is the same as the ith column of B. The outside all produces a 1 if all the entries of the vector are 1. Thus if A and B differ on at least one entry, then all(all(A==B))=0. The construction
if ~all(all(A==B))), program, end
then behaves in the desired way.