Use a for loop to create an array containing 100 elements


1. Some programs have a feature that allows you to quickly prepare a plot of a function over a standard range, such as -10 to +10.This can be handy when you need to select a function for some purpose such as modeling or curve fitting. We can create a VI in LabVIEW that does the same thing because LabVIEW allows you to replace one function with another without breaking all the wires. Create a Function Plot VI for the Sine function that uses a For Loop to evaluate the function over the range -10 to +10, with at least 200 points (for creating a smooth plot).Send the X and sin(X) values to an XY Graph control.

Once your VI is working with the Sine function, replace the Sine function with the following:

a. Sin(X)/X function-what is the minimum value in the range -10 to +10?

b. Asec(X) function-how does the VI respond to undefined values, such as Asec(0)?

Your block diagram should look like this:

1615_5.png

2. Use a For Loop to create an array containing 100 elements between 0 and 500.

3. A classic example of the use of a While Loop is calculating factorials .The factorial of X (an integer) is the product of X and all smaller integers, down to 1. The factorial of 4 is
4 * 3 * 2 * 1 = 24
To calculate a factorial using a While Loop (see Figure), you:
• Send the initial value of X into a shift register that keeps track of the Current Value.
• Use a second shift register to keep track of the increasing product value (initialize with a value of 1).
• Multiply by the current X value and the product from the previous cycle
• Decrement the current X value.
• Loop until the current X value is less than or equal to 1.

Write a VI that calculates factorials using a While Loop. Set the Representation of the controls, indicators, and constants to integer (I32, for example).
a. What is the maximum initial value of X that will work with I32 controls and indicators?
b. What is the maximum initial value of Xthat will work with I64 controls and indicators?
c. What happens if someone tries to use an initial value of X that is too large?

d. Modify the control for the initial value of X to restrict the allowable values that the user can enter to integers between 1 and the maximum possible value from part b.

1663_6.png

Solution Preview :

Prepared by a verified Expert
Other Engineering: Use a for loop to create an array containing 100 elements
Reference No:- TGS01078742

Now Priced at $9 (50% Discount)

Recommended (90%)

Rated (4.3/5)