Skip to content Skip to navigation

Connexions

You are here: Home » Content » Variables in LabVIEW MathScript

Navigation

Content Actions

  • Download module PDF
  • Add to ...
    Add the module to:
    • My Favorites
    • A lens
    • An external social bookmarking service
    • My Favorites (What is 'My Favorites'?)
      'My Favorites' is a special kind of lens which you can use to bookmark modules and collections directly in Connexions. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need a Connexions account to use 'My Favorites'.
    • A lens (What is a lens?)

      Definition of 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.

    • External bookmarks
  • E-mail the authors

Lenses

What is a lens?

Definition of 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 (What does "Affiliated with" mean?)

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.
  • National Instruments

    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.

Also in these lenses

  • NI Signal Processing

    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.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

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

Variables in LabVIEW MathScript

Module by: Anthony Antonacci, Darryl Morrell Based on: Variables in MATLAB by Darryl Morrell

Summary: This module provides a brief introduction to the use of variables in LabVIEW MathScript.

Variables in LABVIEW MATHSCRIPT

A variable in LABVIEW MATHSCRIPT is a named value. Using variables allows us to manipulate values symbolically, which is particularly useful when programming.

Example 1

Suppose we wish to compute the circumference of a circle of diameter 5 units using the formula c = π d c π d . We could first set the variable d to a value of 5:


>> d = 5

d =

    5.000

Then we could compute the circumference and assign its value to the variable c:

>> c = pi*d

c =

    15.708

To execute this command, LABVIEW MATHSCRIPT computes the product of the value of d (which LABVIEW MATHSCRIPT knows because we earlier set it to 5) and the value of pi (which is a pre defined variable in LABVIEW MATHSCRIPT) and stores the value of the product in the variable c.

Variable names must begin with an upper- or lower-case letter. They may contain letters, digits, and underscores; they may not contain spaces or punctuation characters. LABVIEW MATHSCRIPT is case sensitive, so A and a are different variables.

Exercise 1: Valid variable names

Which of the following are valid variable names?

  1. a
  2. B
  3. ecky_ecky_ecky_ecky_ptang_zoo_boing
  4. ecky ecky ecky ecky ptang zoo boing
  5. 2nd
  6. John-Bigboote

Solution 1

  1. Valid.
  2. Valid.
  3. Valid.
  4. Invalid, because the variable name contains spaces.
  5. Invalid, because the variable name begins with a number.
  6. Invalid, because the variable name contains a dash.

LABVIEW MATHSCRIPT has several predefined variables. The most commonly used include

  • ans - the default variable in which computation results are stored.
  • pi - π.
  • i or j - -1 -1 .
Once assigned, variable names remain until they are reassigned or eliminated by the clear command.

LABVIEW MATHSCRIPT variables can contain several types of numerical values. These types include the following:

  • Scalar values - scalar is a mathematical term for a single value (i.e. a number). c and d in Example 1 are scalar variables.
  • Vectors - a vector is an ordered series of numbers.
  • strings - LABVIEW MATHSCRIPT variables may also contain strings of characters.

Comments, questions, feedback, criticisms?

Send feedback