User:Brian P. Josey/Notebook/2010/08/09
Project name | Main project page Previous entry Next entry |
For Loops ContinuedAs a way to challenge myself and test my understanding of everything I've done so far in LabVIEW, I created a simple VI to perform a simple calculation in two ways. The calculation is the sum of a series of numbers from 1 to some number n, expressed as: Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://api.formulasearchengine.com/v1/":): {\displaystyle \sum_{i=1}^n i = \frac {n(n+1)} {2} } This summation is easy to calculate and I learned it in high school, coupled with the need to have steadily increase the size of the new terms, I figured it was a good challenge to ensure I knew where my skills were. I then created this block diagram for this VI: The program is fairly simple. Essentially, I put in a number for n that determines the number of iterations of the for loop, and is plugged into the simplified formula to check the for loop. Inside of the loop, one is added to the number of iterations, which starts at 0 by convention, which is then added to the result of the previous iteration. This value is then displayed on the front panel, along with the value generated by the formula. After the loop finish execution, it should match the value from the formula. Plugging in several numbers, it was successful and worked without any problems. |