# check content of a Matrix

I have a matrix which contain rotated ellipses and points, how can I check if the element in the position {i,j} is either a point or an ellipse?

the code is a bit longer but the structure is like:

matrix = table [ if[condition] , Rotate[Circle, parameters[[i,j]]] ,Point [[i,j]],{j,1,900},{i,1,900}]

then I use Graphics over that matrix but I don't want to show the points, that's why i am asking how to detect the points

• I don't understand the question. It would be best to give an example of such a matrix (a small one, as small as possible while still illustrating the problem) – Szabolcs May 28 '16 at 19:10
• i updated the first post – Alucard May 28 '16 at 19:23

headF1 gets the Head of the expression in the specified part of the matrix. headF2 uses the fact that Part 0 of an expression is its Head.

ClearAll[headF1,headF2]
headF2= #[[## & @@ #2]][] &;

SeedRandom
mat = RandomChoice[{Ellipse[], Point[]}, {5, 3}]


{{Point[], Point[], Ellipse[]}, {Point[], Ellipse[], Ellipse[]}, {Ellipse[], Point[], Ellipse[]}, {Point[], Ellipse[], Ellipse[]}, {Ellipse[], Ellipse[], Ellipse[]}}

headF1[mat, {2, 3}]


Ellipse

headF2[mat, {2, 3}]


Ellipse

• nvm it works but it gives me Rotate, thanks – Alucard May 28 '16 at 19:25
• can you explain me what the #s do in this case? – Alucard May 28 '16 at 19:29
• @Alucard, you can use headF1[mat, {2, 3}] /. Rotate -> Ellipse. Or change the definition headF1 = Head[#[[## & @@ #2]]]/. Rotate -> Ellipse &. – kglr May 28 '16 at 19:30
• @Alucard, #1, #2 are Slots, used as place-holders for un-named arguments. The pure Function headF1 does the same thing as the function with named arguments headF[ matrix_, part : {_, _}] := Head[matrix[[Sequence @@ part]]]. – kglr May 28 '16 at 19:35
• ok i thought i had solved this but it seems this problem is out of my league. how can i force Graphics to act as i wish upon the matrix ? only the points should be transparent or not elaborated at all – Alucard May 28 '16 at 20:32