Connexions

You are here: Home » Content » Programming in LabVIEW MathScript-While Loops
Content Actions
Lenses

What is a lens?

Lenses

A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual Connexions member, a community, or a respected organization.

This content is ...
Affiliated with (?)
This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • This module is included in aLens by: National InstrumentsAs a part of collection:"Introduction to LabVIEW MathScript"

    Comments:

    "This course provides a brief introduction to LabVIEW MathScript, the textual math componenet of LabVIEW. The modules for this course include typical syntax and programming methods commonly used […]"

    Click the "National Instruments" link to see all content affiliated with them.

    National Instruments
Also in these lenses
  • This module is included inLens: Digital Signal Processing with NI LabVIEW and the National Instruments Platform
    By: Sam ShearmanAs a part of collection:"Introduction to LabVIEW MathScript"

    Comments:

    "Tutorial / Introduction to LabVIEW MathScript, a text-based component of National Instruments LabVIEW that allows you to run your .m file scripts in LabVIEW Virtual Instruments."

    Click the "NI Signal Processing" link to see all content selected in this lens.

    NI Signal Processing
Tags

(?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

Programming in LabVIEW MathScript-While Loops

Module by: Anthony Antonacci, Darryl Morrell Based on: Programming in MATLAB-While Loops by Darryl Morrell

Summary: This is a tutorial on using while loops in LabVIEW MathScript.

The While Loop

The while loop is similar to the for loop in that it allows the repeated execution of LABVIEW MATHSCRIPT statements. Unlike the for loop, the number of times that the LABVIEW MATHSCRIPT statements in the body of the loop are executed can depend on variable values that are computed in the loop. The syntax of the while loop has the following form:
while expression
    % LABVIEW MATHSCRIPT command 1
    % LABVIEW MATHSCRIPT command 2
    % More commands to execute repeatedly until expression is not true
end
where expression is a logical expression that is either true or false. (Information about logical expressions is available in Programming in LABVIEW MATHSCRIPT-Logical Expressions.) For example, consider the following while loop:
n = 1
while n < 3
    n = n+1
end
This code creates the following output:
n =

     1

n =

     2

n =

     3
Note that in all of this example, the LABVIEW MATHSCRIPT commands inside the while loop are indented relative to the while and end statements. This is not required by LABVIEW MATHSCRIPT but is common practice and makes the code much more readable.

Comments, questions, feedback, criticisms?

Send feedback