I have a 200 by 200 matrice named
theta which shows an angle in a 200 by 200 box. The angle is in the interval [-90,90]. When I plot theta in a 2d plane, there are some positions in which the angle jumps from -90 to 90. This is shown for a particular choice case in the below picture:
As it is clear from the picture, there are positions where theta jumps from -80 to 80. I want to make theta even by adding (or subtracting) 180 to it in the positions with sharp change. The reason that I can only add (or subtract) 180 is that in the problem that I am trying to solve, has a symmetry which allows adding 180 degrees to the data. I appreciate it if someone could solve this problem.
The script that I use to plot it is:
[a, b] = contourf(theta, 88); set(b,'EdgeColor','none'); colormap(summer); shading flat; colorbar;
Using the proposed answer I get the following: