How do I count non-zero entries in a vetor matrix
How do I count non-zero entries in a vetor matrix
(OP)
I have a vector matrix with 20 entries. If I use the length(x)= ## comand it counts out the number of possible entires in my vector but I need it to only count the non-zero entries. I'm not very good with mathcad so does anyone have any suggestions?
I've attached and example of what I have but someone before me wrote it so I don't understand how it works or what it's doing so therefore I can't duplicate it for a different vector were some of the entries are negative.
I've attached and example of what I have but someone before me wrote it so I don't understand how it works or what it's doing so therefore I can't duplicate it for a different vector were some of the entries are negative.





RE: How do I count non-zero entries in a vetor matrix
RE: How do I count non-zero entries in a vetor matrix
The attached file does it for you - hope this helps you. You needed to setup a loop (similar to what ishvaaag suggested).
RE: How do I count non-zero entries in a vetor matrix
just re-read what you were looking for; i.e. non-zeros...
To do this you need to change the 'n' in the (n vn) term within the loop to 'length(Space)-n' and then you'll have the number of non-zero terms in your data set.
Uploading MathCad died for some reason, hence the long-hand version shown in above paragraph...sorry!