It is my understanding that you want to develop a collision detection system between the mouse and the walls for a maze. You do not want to use if-else statements to do the same.
It is my assumption that you have been able to extract the co-ordinates of the walls from the image. If not, you can refer to the code attached here.
"maze_solution" is one of the several submissions in MATLAB File Exchange on MATLAB Central which is a forum for our product users to interact, exchange information and knowledge, without MathWorks' involvement. Feel free to contact the author of this submission directly for specific questions about the implementation
A workaround could be to use for loops to achieve the same result. An array can be created in which 2 points(that define a line segment) can be added for every wall in the maze. You could also define 'x' points as extremities which will define the border for the mouse(e.g. 4 corners if the mouse has a rectangular bounding box). A for loop can then be added to check for any collisions. You can further refer to this answer to know about collsion detection between a point and a line
Here is a pseudo code for the same:
for i = 1:length(Wall_Array)
for i2 = 1:length(mouse_Array)
if shortest_distance(mouse_Array(i2), Wall_Array(i) == 0)