1 / 22

EET 2259 Unit 10 Clusters and Matrices

EET 2259 Unit 10 Clusters and Matrices. Read Bishop, Sections 6.4 to 6.10. Lab #10 and Homework #10 due next week. Exam #2 next week. Polymorphism. Polymorphism is a feature of functions in modern programming languages such as LabVIEW.

rasia
Download Presentation

EET 2259 Unit 10 Clusters and Matrices

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EET 2259 Unit 10Clusters and Matrices • Read Bishop, Sections 6.4 to 6.10. • Lab #10 and Homework #10 due next week. • Exam #2 next week.

  2. Polymorphism • Polymorphism is a feature of functions in modern programming languages such as LabVIEW. • It lets a single function work on inputs of different dimensions and data types. • This allows one function to do the work that you’d need several different functions to do in older languages that don’t have polymorphism. (Bishop, p. 310)

  3. Polymorphism Example: Add • LabVIEW’s Add function is an example of a polymorphic function. • It can add a scalar plus a scalar, or an array plus an array, or a scalar plus an array. • In non-polymorphic languages, this would require several different functions.

  4. Clusters • Recall that an array is a variable-sized collection of elements that are all of the same data type (such as numeric, string, or Boolean). • In contrast, a cluster is a fixed-sized collection of elements of mixed data types. • While a cluster can group different types of controls or different types of indicators, it cannot group controls together with indicators. (Bishop, p. 313)

  5. Usefulness of Clusters • Clusters are useful when you have a related group of elements of different data types that you want to associate with each other. • Example: you might group a string containing a person’s name together with an integer containing his/her age and a Boolean indicating his/her citizenship status. • Clusters often let you simplify block diagrams by reducing the number of wires on the diagram. (Bishop, p. 314)

  6. Creating a Cluster of Controls or Indicators • To create a cluster of controls or indicators: • Place a cluster shell on the front panel from the Controls >> Modern >> Array, Matrix & Cluster palette. • Place controls or indicators inside that cluster shell. (Bishop, pp. 314-315)

  7. Brown or Pink? • On the block diagram, cluster terminals and cluster wires are colored brown if all of the items in the cluster are numeric. • But the terminals and wires are colored pink if one or more of the items are non-numeric.

  8. Order within a Cluster • Individual items within a cluster are referred to by the order in which they were placed in the cluster. • The first item placed in a cluster becomes element 0, the next item placed in the cluster becomes element 1, and so on. • To change the order, right-click a cluster’s border on the front panel and select Reorder Controls in Cluster. (Bishop, p. 316)

  9. Connecting Control Cluster to Indicator Cluster • You can wire a control cluster to an indicator cluster if they contain the same number of elements and if the data types of the corresponding elements match. • Example: if a control cluster’s element 0 is a string control and its element 1 is a numeric control, you could not wire it to an indicator cluster whose element 0 is a numeric indicator and whose element 1 is a string indicator. (Bishop, p. 317)

  10. Cluster Functions • LabVIEW provides several functions for working with clusters, including: • Unbundle • Unbundle By Name • Bundle • Bundle By Name • These and others are on the Functions >> Programming >> Cluster & Variant palette. (Bishop, p. 319)

  11. Unbundle and Unbundle By Name • The Unbundle and Unbundle By Name functions are used to split a cluster into its individual objects. (Bishop, p. 323) • Recommendation: Use Unbundle By Name instead of Unbundle.

  12. Bundle and Bundle By Name • The Bundle and Bundle By Name functions are used to replace objects in an existing cluster, or to assemble objects into a new cluster. (Bishop, p. 319) • Recommendation: Use Bundle By Name instead of Bundle.

  13. Cluster Example: Displaying Multiple Plots on a Chart • Many LabVIEW indicators and functions have input terminals that can accept clusters. • Example: To display more than one plot on a waveform chart, bundle the data together using the Bundle function. (We’ll discuss charts in more detail next week.) (Bishop, p. 351)

  14. Matrices • A matrix is a two-dimensional array of numbers. (And a vector is a one-dimensional array of numbers.) • The branch of math called linear algebra studies rules and techniques for manipulating matrices and vectors. • Scientists and engineers use matrices and vectors to solve many types of problems.

  15. Matrices in LabVIEW • LabVIEW has a matrixdatatype that is basically a special case of the array datatype. • A matrix must be two-dimensional, and it can only hold numbers (real or complex). • LabVIEW does not have a special vectordatatype: just use a 1-D array.

  16. LabVIEW Matrix Functions • LabVIEW has a large collection of powerful functions that work on matrices and vectors. • See the Programming > Array > Matrix palette and the Mathematics > Linear Algebra palette.

  17. Solving Systems of Linear Equations • As a simple example, matrices can be used to solve systems of linear equations, which arise in many applications. • Applications include the circuit-analysis techniques called mesh analysis and nodal analysis that you studied in DC Circuits (EET 1150). • Suppose we want to find the currents in the circuit on the next slide….

  18. Figure 9–14

  19. Mesh Analysis • Mesh analysis (also called “loop analysis”) involves three steps: • Apply Kirchhoff’s Voltage Law (KVL) around each loop to set up a system of linear equations. LabVIEW can’t help with this step; you have to do it by hand. • Solve the system of linear equations. Doing this by hand can be very tedious, but with LabVIEW it’s very easy. • Interpret the results of Step 2.

  20. Step 1. Applying KVL • In our circuit, applyingKVL to the three loops gives us the following system of equations:

  21. Step 2. Solving the System of Equations in LabVIEW

  22. Step 3. Interpreting the Results • To interpret the results we must recognize that in the original circuit, • This gives us the current through each resistor.

More Related