Skip to main content
1-Visitor
January 21, 2014
Solved

How to create a counter that counts iteratively?

  • January 21, 2014
  • 2 replies
  • 1723 views

In the attached MathCAD 14 worksheet, I am attempting to create a counter "v" that counts the number of times a value in an array c.a is below 1.5*hef. Is this something easy to do? I have attempted to do this with a "for" function but am not recieving the result I'm looking for.

Best answer by GuyB

I wasn't sure what you wanted. Two guesses enclosed. The relevant part is copied as a picture, additional comments included in the attached Mathcad sheet.

- Guy

PS Note that the vectors (and counter) start at j=0, though your first definition of c(sub)a begins with j=1 ... even though you define ORIGIN=0.

Picture2.jpg

2 replies

GuyB1-VisitorAnswer
1-Visitor
January 21, 2014

I wasn't sure what you wanted. Two guesses enclosed. The relevant part is copied as a picture, additional comments included in the attached Mathcad sheet.

- Guy

PS Note that the vectors (and counter) start at j=0, though your first definition of c(sub)a begins with j=1 ... even though you define ORIGIN=0.

Picture2.jpg

25-Diamond I
January 21, 2014

You may achieve the same results as shown by Guy using for-loops more compact that way:

21.01.png

Are you aware that your vector c.a contains 5 elements? Because ORIGIN is 0 (and thats a reasonable default value anyway) and you defined beginning from c.a[1, the first element is (default) 0. If thats not on purpose I would suggest you begin your definitions with c.a[0 instead if c.a[1. Second best is setting ORIGIN to 1.

21.01.png