Summary: In this exercise, the objective is to save a 2D array in a text file so a spreadsheet application can access the file and to display numeric data in a table. Complete the following steps to examine a VI that saves numeric arrays to a file in a format you can access with a spreadsheet.
Spreadsheet Example VI located in
the C:\Exercises\LabVIEW Basics I
directory. The front panel in Figure 1 is
already built.
![]() Figure 1 |
Choose file to write dialog box
appears, save the file as wave.txt in the
C:\Exercises\LabVIEW Basics I directory and
click the OK button. Later, you will
examine this file.
![]() Figure 2 |
Sine Pattern VI
located on the Functions>>All
Functions>>Analyze>>Signal Processing>>Signal
Generation palette returns a numeric array of
128 elements containing a sine pattern. The constant
90.0, in the second instance of the
Sine Pattern VI, specifies the phase of
the sine pattern or cosine pattern.
The Uniform White Noise
VI located on the Functions>>All
Functions>>Analyze>>Signal Processing>>Signal
Generation palette returns a numeric array of
128 elements containing a noise pattern.
Build Array
function located on the Functions>>All
Functions>>Array palette builds the 2D array
from the sine array, noise array, and cosine array,
as shown in Figure 3.
![]() Figure 3 |
Transpose 2D
Array function located on the
Functions>>All Functions>>Array palette
rearranges the elements of the 2D array so element
![]() Figure 4 |
Write To Spreadsheet
File VI located on the Functions>>All
Functions>>File I/O palette formats the 2D
array into a spreadsheet string and writes the
string to a file. The string has the format shown in
Figure 5, where an arrow indicates
a tab, and a paragraph symbol (¶) indicates an
end of line character.
![]() Figure 5 |
Number To
Fractional String function located on the
Functions>>All
Functions>>String>>String/Number Conversion
palette converts an array of numeric values to an
array of strings that the table displays.
Build Array function.
wave.txt file using a word processor
or spreadsheet application and view its contents.
wave.txt. The sine waveform data
appear in the first column, the random waveform data
appear in the second column, and the cosine waveform
data appear in the third column.
Comments, questions, feedback, criticisms?
"A full introductory course on programming with LabVIEW."