Example Code

Sorting a 1D Array and Providing an Index Matrix

Code and Documents

Attachment

This example VI sorts a 1D array and provides an index matrix.

This VI uses the Index and Bundle Cluster Array function to bundle an array and a set of indices. Then, this VI uses the Sort 1D Array function and a For Loop to generate a sorted array.

The following example demonstrates the sorting capabilities of this VI.
unsorted array A=[5 4 5 3 1 2]
sorted array B = [1 2 3 4 5 5]
index of A after sorted = [4 5 3 1 0 2]

This VI mimics the sort.m function found in The MathWorks, Inc. MATLAB® software.

MATLAB® is a registered trademark of The MathWorks, Inc. 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors