6. Macierze i klastry.pdf
(
974 KB
)
Pobierz
Microsoft Word - PW 6. Macierze i klastry.doc
prof. dr hab. Krzysztof Jemielniak
PRZYRZĄDY
WIRTUALNE
Część 6
Macierze i
klastry
http://www.cim.pw.edu.pl/labview
k.jemielniak@wip.pw.edu.pl
http://www.cim.pw.edu.pl/kjemiel
ST 149, tel. 660 8656
Politechnika Warszawska, Wydział Inżynierii Produkcji, Instytut Technologii Maszyn
Warszawa 2003
PRZYRZĄDY
WIRTUALNE
Macierze
(Arrays)
• Zbiór elementów tego samego typu
• Jeden lub więcej wymiarów, do
2
elementów na
wymiar
• Dostęp do poszczególnych elementów przez indeks
• Pierwszy element ma indeks
0
31
indeks
Macierz 10-elementowa
1.2 3.2 8.2 8.0 4.8 5.1 6.0 1.0 2.5 1.7
0 1 2 3 4 5 6 7 8 9
Macierz 2D
0
1
2
3
4
0 1 2 3 4 5 6
5 wierszy, 7 kolumn:
macierz o 35 elementach
Politechnika Warszawska, Wydział Inżynierii Produkcji, Instytut Technologii Maszyn
Arrays group data elements of the same type. An array consists of elements and dimensions. Elements are
the data that make up the array. A dimension is the length, height, or depth of an array. An array can have
one or more dimensions and as many as 2^31 – 1 elements per dimension, memory permitting.
You can build arrays of numeric, Boolean, path, string, waveform, and cluster data types. Consider using
arrays when you work with a collection of similar data and when you perform repetitive computations.
Arrays are ideal for storing data you collect from waveforms or data generated in loops, where each iteration
of a loop produces one element of the array.
Array elements are ordered. An array uses an index so you can readily access any particular element. The
index is zero-based, which means it is in the range 0 to
n
– 1, where
n
is the number of elements in the array.
For example,
n
= 9 for the nine planets, so the index ranges from 0 to 8. Earth is the third planet, so it has an
index of 2.
A 2D array is analogous to a spreadsheet or table.
Example: Temperature readings and time stamp. One column
is time values, and the other column is readings.
Point out element (2,3) and element (3,2) on the slide.
Be careful to specify the element you really want. Example: The
first element in an array is array (0), not array(1).
Wstawianie macierzy na panelu czołowym
Z palety
Controls
>>
All Controls
>>
Array and Cluster
wybierz
Array
Zrzuć „skorupę”
na panel
Politechnika Warszawska, Wydział Inżynierii Produkcji, Instytut Technologii Maszyn
To create an array control or indicator as shown, select an array on the
Controls»All Controls»Array &
Cluster
palette, place it on the front panel, and drag a control or indicator into the array shell. If you attempt
to drag an invalid control or indicator such as an XY graph into the array shell, you are unable to drop the
control or indicator in the array shell.
You must insert an object in the array shell before you use the array on the block diagram. Otherwise, the
array terminal appears black with an empty bracket.
Wstawianie macierzy na panelu
czołowym (cd.)
Umieść odpowiedni obiekt (np. zadajnik numeryczny
Numeric Control
) w „skorupie”
Dodawanie
wymiaru macierzy
Politechnika Warszawska, Wydział Inżynierii Produkcji, Instytut Technologii Maszyn
To add dimensions to an array one at a time, right-click the index display and select
Add Dimension
from
the shortcut menu. You also can use the Positioning tool to resize the index display until you have as many
dimensions as you want.
Tworzenie stałej macierzowej (diagram)
1. Wybierz skorupę
Array Constant
z
palety
Array
2. Umieść potrzebny obiekt w
skorupie (tu stała boolowska)
Politechnika Warszawska, Wydział Inżynierii Produkcji, Instytut Technologii Maszyn
Tworzenie macierzy przy pomocy pętli
•
Pętle domyślnie kumulują macierze (auto
indeksowanie)
•
Auto indeksowanie można wyłączyć
Politechnika Warszawska, Wydział Inżynierii Produkcji, Instytut Technologii Maszyn
If you wire an array to a For Loop or While Loop input tunnel, you can read and process every element in
that array by enabling auto-indexing. When you auto-index an array output tunnel, the output array receives
a new element from every iteration of the loop. The wire from the output tunnel to the array indicator
becomes thicker as it changes to an array at the loop border, and the output tunnel contains square brackets
representing an array, as shown in the following illustration.
Disable auto-indexing by right-clicking the tunnel and selecting
Disable Indexing
from the shortcut menu.
For example, disable auto-indexing if you need only the last value passed to the tunnel in the previous
example, without creating an array.
Note
Because you can use For Loops to process arrays an element at a time, LabVIEW enables auto-
indexing by default for every array you wire to a For Loop. Auto-indexing for While Loops is disabled by
default. To enable auto-indexing, right-click a tunnel and select
Enable Indexing
from the shortcut menu.
If you enable auto-indexing on an array wired to a For Loop input terminal, LabVIEW sets the count
terminal to the array size so you do not need to wire the count terminal. If you enable auto-indexing for more
than one tunnel or if you wire the count terminal, the count becomes the smaller of the choices. For example,
if you wire an array with 10 elements to a For Loop input tunnel and you set the count terminal to 15, the
loop executes 10 times.
Plik z chomika:
Przechowalnia5
Inne pliki z tego folderu:
1. Podstawy, panel czolowy.pdf
(1133 KB)
2. Diagram, funkcje palety narzedzi.pdf
(831 KB)
3. Tworzenie VI, subVI, debugging.pdf
(689 KB)
4. DAQ, petla while.pdf
(1055 KB)
5. Petla for, przebiegi czasowe, struktury, wzory.pdf
(913 KB)
Inne foldery tego chomika:
Automation Studio
automatyka
beckhoff
CAD electronics automation GAP
CAD electronics automation GAP(1)
Zgłoś jeśli
naruszono regulamin