Download Unit 10 PowerPoint Slides

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
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.
Floyd, Digital Fundamentals, 10th ed
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)
Floyd, Digital Fundamentals, 10th ed
Polymorphism Example: Add



LabVIEW’s Add function is an
example of a polymorphic
function.
It can add a scalar plus a
scalar, or a scalar plus an
array, or an array plus an array.
In non-polymorphic languages,
this would require several
different functions.
Floyd, Digital Fundamentals, 10th ed
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.
(Bishop, p. 313)
Floyd, Digital Fundamentals, 10th ed
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.
Floyd, Digital Fundamentals, 10th ed
(Bishop, p. 314)
Creating a Cluster of Controls or
Indicators

1.
2.
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. (A cluster can contain either
controls or indicators, but it cannot contain
both.)
(Bishop, pp. 314-315)
Floyd, Digital Fundamentals, 10th ed
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 nonnumeric.
Floyd, Digital Fundamentals,
10 ed

th
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.
Floyd, Digital Fundamentals, 10th ed
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)
Floyd, Digital Fundamentals, 10th ed
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.
Floyd, Digital Fundamentals, 10th ed
(Bishop, p. 319)
Unbundle and Unbundle By Name

The Unbundle and Unbundle By Name
functions are used to split a cluster into its
individual objects. (Similar to the Index
Array function for arrays.)
Recommendation: Use Unbundle By Name
instead
of Unbundle.
Floyd, Digital Fundamentals,
10 ed

th
Bundle

One use of the Bundle function is to
assemble objects into a new cluster.
(Similar to one use of the Build Array
function for arrays.)
Recall that the Build Array function can also be used to add
elements to an existing array. There is no comparable
Floyd, Digital Fundamentals, 10th ed
function for clusters, since their size cannot change.

Bundle and Bundle By Name

Another use of the Bundle function is to
change the values of one or elements in an
existing cluster. The Bundle By Name
function can also be used in this way.
Recommendation: Use Bundle By Name
instead of Bundle.
Floyd, Digital Fundamentals, 10 ed

th
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)
Floyd, Digital Fundamentals, 10th ed
Matrices



A matrix is a two-dimensional array of
numbers. (And a vector is a onedimensional 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.
Floyd, Digital Fundamentals, 10th ed
Matrices in LabVIEW


LabVIEW has a matrix datatype 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 vector
datatype: just use a 1-D array.
Floyd, Digital Fundamentals, 10 ed

th
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.
Floyd, Digital Fundamentals, 10th ed
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 loop analysis and
nodal analysis that you studied in DC
Circuits (EET 1150).



Suppose we want to find the current through
each resistor in the circuit on the next slide….
Floyd, Digital Fundamentals, 10th ed
Figure 9–14
Principles of Electric Circuits: Conventional Current Version, 8e
By Thomas L. Floyd
© 2007 Pearson Education, Inc.
Pearson Prentice Hall
Upper Saddle River, NJ 07458
Loop Analysis
Loop analysis (also called “mesh analysis”)
involves three steps:

1.
2.
3.
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 tedious, but with LabVIEW
it’s easy.
Interpret the results of Step 2.
Floyd, Digital Fundamentals, 10th ed
Step 1. Applying KVL

In our circuit, applying
KVL to the three loops
gives us the following
system of equations:
44,500 𝐼𝐴 − 22,000 𝐼𝐵 − 7500 𝐼𝐶 = 0
−22,000 𝐼𝐴 + 30,200 𝐼𝐵 − 8200 𝐼𝐶 = 12
−7500 𝐼𝐴 − 8200 𝐼𝐵 + 25,700 𝐼𝐶 = 0
Floyd, Digital Fundamentals, 10th ed
Step 2. Solving the System of
Equations in LabVIEW
44,500 𝐼𝐴 − 22,000 𝐼𝐵 − 7500 𝐼𝐶 = 0
−22,000 𝐼𝐴 + 30,200 𝐼𝐵 − 8200 𝐼𝐶 = 12
−7500 𝐼𝐴 − 8200 𝐼𝐵 + 25,700 𝐼𝐶 = 0
Floyd, Digital Fundamentals, 10th ed
Step 3. Interpreting the Results


To interpret the results
we must recognize that
in the original circuit,
𝐼1 = 𝐼𝐴
𝐼2 = 𝐼𝐵 − 𝐼𝐴
𝐼3 = 𝐼𝐶 − 𝐼𝐴
𝐼4 = 𝐼𝐵 − 𝐼𝐶
𝐼𝐿 = 𝐼𝐶
This gives us the current
through each resistor.
Floyd, Digital Fundamentals, 10th ed
Converting Between Arrays,
Clusters, and Matrices


In some cases it
makes sense to
convert an array
to a cluster (or
vice versa) or to
convert an array
to a matrix (or
vice versa).
For such cases, LabVIEW provides
conversion functions on the Array palette.
Floyd, Digital Fundamentals, 10th ed