# Count from MatrixForm in mathematica

• Mathematica

## Main Question or Discussion Point

Count from "MatrixForm" in mathematica!!

Hi every one, I really need help on this task..

how do I Count only the zeros elements from a MatrixForm in MATHEMATICA

Suppose I have a Matrix 100X100 full with numbers and
I just need to know how many zero is there on this matrix

thanks

Related MATLAB, Maple, Mathematica, LaTeX News on Phys.org

First, all the various "Form"s are wrappers that turn an ordinary simple Mathematica value into something for display and aren't usually for further processing.

So, if you have your matrix before you put it into MatrixForm then you can do this

In:= m=Table[RandomInteger[{5},{5}]

Out= {{1,0,1,1,1},{0,1,1,0,0},{1,0,0,1,0},{0,0,0,0,0},{1,0,1,1,0}}

In:= Count[Flatten[m],0]

Out= 14

and that has successfully counted the zeros in the matrix.

But

In:= Count[MatrixForm[m],0]

Out= 0

In:= Count[Flatten[MatrixForm[m]],0]

Out= 0

So if you want to see a pretty desktop published version of your matrix... use MatrixForm, but if you want to get any work done on your matrix then do not use MatrixForm.

thanks its work 100%