Connexions

You are here: Home » Content » Programming in LabVIEW MathScript-Simple While Loop Exercises
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-Simple While Loop Exercises

Module by: Anthony Antonacci, Darryl Morrell Based on: Programming in MATLAB-Simple While Loop Exercises by Darryl Morrell

Summary: This module provides several simple exercises designed to test and increase your understanding of while loops in LabVIEW MathScript.

Some While Loop Exercises

Problem 1
How many times will this loop print 'Hello World'?
n = 10;
while n > 0
    disp('Hello World')
    n = n - 1;
end
[ Click for Solution 1 ]
Solution 1
10 times.
[ Hide Solution 1 ]
Problem 2
How many times will this loop print 'Hello World'?
n = 1;
while n > 0
    disp('Hello World')
    n = n + 1;
end
[ Click for Solution 2 ]
Solution 2
This loop will continue to print 'Hello World' until the user stops the program. You can stop a program by holding down the 'Ctrl' key and simultaneously pressing the 'c' key.
[ Hide Solution 2 ]
Problem 3
What values will the following LABVIEW MATHSCRIPT code print?
a = 1
while a < 100
    a = a*2
end
[ Click for Solution 3 ]
Solution 3
a =
     1
a =
     2
a =
     4
a =
     8
a =
    16
a =
    32
a =
    64
a =
   128
[ Hide Solution 3 ]
Problem 4
What values will the following LABVIEW MATHSCRIPT code print?
a = 1;
n = 1;
while a < 100
    a = a*n
    n = n + 1;
end
[ Click for Solution 4 ]
Solution 4
a =
     1
a =
     2
a =
     6
a =
    24
a =
   120
[ Hide Solution 4 ]

Comments, questions, feedback, criticisms?

Send feedback