Use islogical() instead of comparing the class.
If you must compare the class then use strcmp instead of == .
If you must use == then use R2016b or later and
if string(class(image)) == 'logical'
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!