Section 9 Activity 7-2: Array Acrobatics
推荐给好友
打印
加入收藏
更新于2008-04-29 11:03:52

Activity 7-2: Array Acrobatics

Confused yet? You'll get a better feel for arrays as you work with them. In this exercise, you will finish building a VI that concatenates two arrays and then indexes out the element in the middle of the new concatenated array.


1. Open Array Exercise.vi, located in EVERYONE\CH07.

The front panel contains two input arrays (each showing three elements), two digital controls, and an output array (showing eight elements). The VI will concatenate the arrays and the control values in the following sequence to create the new array.

Initial Array + Element 1 + Element 2 + Terminal Array

The front panel is already built. You will finish building the diagram. Note that an array control or indicator will appear grayed out until you or the program assigns it some data (see Figure 7.31).

Figure 7.31. Array Excersise.vi front panel

2. Build the block diagram in Figure 7.32. Use the Help window to find the correct terminals on the functions.

Figure 7.32. Array Exercise.vi block diagram



Build Array Function

Build Array function (Programming>>Array palette). In this exercise, concatenates the input data to create a new array in the following sequence: Initial Array + Element 1 + Element 2 + Terminal Array.



Build Array Function

The function looks like the icon at the left when placed in the diagram window. Place the Positioning tool on the lower-middle edge and resize the function with the resize handles until it includes four inputs.



Array Input



Element Input

The inputs will automatically detect whether you are wiring an array or an element. The symbols at the left indicate whether an input is an array or an element.



Array Size Function

Array Size function (Programming>>Array palette). Returns the number of elements in the concatenated array.



Index Array Function

Index Array function (Programming>>Array palette). In this exercise, returns the element in the middle of the array.


3. Return to the front panel and run the VI. Try several different number combinations.

4. Save the finished VI in your MYWORK directory and close the VI.

You might also want to look through the programs in EXAMPLES/GENERAL/ARRAYS.LLB in the LabVIEW directory, to see some other things you can do with arrays. These examples can be easily found using the NI Example Finder (from the Help>>Find Examples menu) by selecting Browse according to: Directory Structure and then navigating the tree control to general/arrays.llb.

 

<<PREV    NEXT>>




 
关于我们 | 诚邀加盟 | 客户服务 | 相关法律 | 网站地图 | 友情链接 | 服务信箱:service@eefocus.com
© 2006 与非门科技信息咨询(北京)有限公司 All Rights Reserved.