I have big triangular matrix.

which has relevant data marked by different colours. I want to remove conditionally the points marked by greenish-yellowish contours:
- Remove greedily on the area of non-linear objects
- Remove lazily on the area of linear objects with probability 50%
My attempt
I run based on Shai's comment
% remove linear things on nonlinear area lazily: matrix(97:103, 1:98)
% remove linear things greedily elsewhere
for row=0:97
for column=0:111
% Lazy removal
if and(row > 97, row < 104)
if and(column > 0, column < 98)
if randn > 0
matrix( matrix < 9 ) = 0;
end
end
end
% Greedy removal
if or(column < 97, column > 104)
% Remove all points in these regions because no linear objects here
matrix(:, 1:97) = 0;
matrix(:, 104:111) = 0;
end
end
end
I get

which is lot better than the unconditional removal

but still the conditional part of lazy removal can be improved. I think you cannot use here Shai's shorter version, and nested loops must be used because you have conditional removal.
You cannot use contour lines, like contour(matrix, clines) because the non-linear objects cover the linear objects too.
So you need conditional removal by selecting specific area of the figure for greedy removal and lazy removal.
Daniel R's command, contour(...,'ShowText','on'), does not seem to help us here, and we cannot simply remove by value.
I think the following figure shows the zero points, probably singularities , because there should be 111 singularities in the figure.
Does the following figure show singularities or only zero values of the data?

How can you apply a specific removal rule to the area of linear objects?
How can you remove conditionally the points that are marked by greenish-yellowish color in the triangular matrix in Matlab?

