Civil / Environmental Engineers

 
Home | Civil/Environmental engineerin | Earthwork/grading engineering | Erosion control engineering | Soil/Groundwater environmental | Storm/Flood engineering | Surveying & Geomatics | Traffic Engineering | Waste disposal & treatment
  Position:Home>Civil/Environmental engineerin>Article Content
How do I count non-zero entries in a vetor matrix
Source:Internet Author:Unknow Pubdate:2010-02-19  
frogger79 (Structural) 5 Feb 10 17:19
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.
  • http://files.engineering.com/getfile.aspx?folder=ac4804f6-500e-40f3-8437-dc


ishvaaag (Structural) 8 Feb 10 12:31
You need to count them by inspection, i.e., build a subroutine that examines every number in the vector and adds to a counter that first is initialized to zero if and only if the current number is other than zero, then once examined all numbers produce the final status of the counter as output. Ensure that your tolerance identifies well what for you is a zero, otherwise you'll get wrong values by your criteria.

字串3



Eyeoftheneedle (Marine/Ocean) 19 Feb 10 6:10
frogger79

The attached file does it for you - hope this helps you.  You needed to setup a loop (similar to what ishvaaag suggested).   
  • http://files.engineering.com/getfile.aspx?folder=56f5fc8b-9951-43ad-a037-c2


Eyeoftheneedle (Marine/Ocean) 19 Feb 10 7:00
frogger79,
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!

(Click:
Previous:Building Sub Floor Drainage   Next:Nothing
[Add TO Favorites] [TOP] [PRINT] [CLOCE WINDOWS]  
  Hot Article
·Turning radius for Truck & RV
·Shrink/swell factors for earth
·Converting mm Hg to psia
·DESIGN OF GRILLAGE FOUNDATION
·Fire Truck Turning template
·I-beam torsional stress calcul
·School Bus Parking Lot Design
·UG HDPE pipe- thrust block req
·Haunches of pipe?
·Smelly vent stack.
·IDF curves HELP
·How to read a pump curve corre
  Related Articles
·Water Treatment
·PE April 2008
·Reverse Curves
·Choosing between environmental
·TL rating for Strong-Post W-Be
·Score Lines in S.O.G.
·SEPA and HPA Requirements
·concrete pipe encasement
·hydraulic design of stilllling
·seeking advice
·Working From Home
·Design & analysis of Frame
Cheap LouisVuitton Bags Civil / Environmental Engineers Structural Engineers Aeronautic Engineers Automotive Engineers Chemical Engineers Geotechnical Engineers Industrial / Manufacturing Engineers Materials Engineers Computer Engineers Agricultural Engineers Mechanical Engineers Petroleum Engineers Bioengineers Military Engineers