<< Chapter < Page Chapter >> Page >
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.

Suppose we wish to compute the circumference of a circle of diameter 5 units using the formula 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.

Valid variable names

Which of the following are valid variable names?

  • a
  • B
  • ecky_ecky_ecky_ecky_ptang_zoo_boing
  • ecky ecky ecky ecky ptang zoo boing
  • 2nd
  • John-Bigboote

  • Valid.
  • Valid.
  • Valid.
  • Invalid, because the variable name contains spaces.
  • Invalid, because the variable name begins with a number.
  • 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 .
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 are scalar variables.
  • Vectors - a vector is an ordered series of numbers.
  • strings - LABVIEW MATHSCRIPT variables may also contain strings of characters.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Introduction to labview mathscript. OpenStax CNX. Aug 06, 2006 Download for free at http://cnx.org/content/col10370/1.3
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Introduction to labview mathscript' conversation and receive update notifications?

Ask