Matlab program with or, algorithm