From 9:00 AM - 12:00 PM CDT on Saturday, June 6th, will be undergoing system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Organizing Data with Different Types and Sizes in Variables (MathScript RT Module)

LabVIEW 2012 MathScript RT Module Help

Edition Date: June 2012

Part Number: 373123C-01

»View Product Info
Download Help (Windows Only)

Use cell arrays to store and organize data in a single variable. Cell arrays contain cells, or elements, and every cell can store data with a different type or size than the other cells in the cell array. Like structures, cell arrays allow you to organize data in a single variable; however, cell arrays are useful for holding an array of different-sized strings or arrays. The following example shows how to define a cell array that stores a string value, a matrix of integers, and a numeric value:

X(1) = {'string'};

X(2) = {[1 3 5; 2 4 6]};

X(3) = {45.5};

In this example, X is a cell array with three cells.

Defining Cell Arrays that Store Structures and Other Cell Arrays

Cell arrays also can store data types that organize data in a variable, like structures and other cell arrays. The following example shows how to define a cell array that stores a structure that stores a cell array:

s.f = {[2 4 6], [1 3 5 7 9]};

A(1) = {s};

In the previous example, the first line defines the structure s with the field f that stores a cell array with two different-sized vectors. The second line defines the cell array A that stores the structure s that stores the cell array that stores the vectors.

The following illustration shows the different components of this example in the Variable List of the LabVIEW MathScript Window:

You also can create a cell array by passing a 1D array of strings from the block diagram to a MathScript Node, and the LabVIEW array becomes a cell array in the MathScript environment.

Refer to the MathScript Euler in the labview\examples\MathScript directory for an example of using a cell array.


Not Helpful