Pages

Monday 17 September 2012

Defining Scalar Variables

 

A variable is a name made of a letter or a combination of several letters (and digits) that is assigned a numerical value. Name of variables must begin with a letter. After the first letter, any number of digits or underscores may be used.

Rules About Variable Name
· Variable name can be up to 31 characters long.
· Can contain letters, digits, and the underscore character.
· Must begin with a letter.
· MATLAB is case sensitive; it distinguishes between uppercase and lowercase letters. For example, FF, Ff, fF, and ff are the names of four different variables.
· Avoid using the names of a built-in function for a variable (i.e. avoid using: sin, tan, exp, sqrt, etc.)

Predefined Variables
A number of frequently used variables are already defined when MATLAB is started. Some of the predefined variables are:



Table : predefined Variables
Predefined Variables Description
ans A variable that has the last expression that was not assigned to a specific variable. If the user does not assign the value of an expression to a variable, MATLAB automatically stores the result in ans.
pi The π number, π = 3.14159
eps The smallest difference between two numbers. Equal to 2^(-52), which is approximately 2.2204e-016.
inf Used for infinity.
i Imaginary unit, defined as , which is 0+1.0000i.
j Same as i.
NaN Stands for Not a number. Used when MATLAB cannot determine a valid numeric value. For example 0/0.














1 comment:

  1. Win Exciting and Cool Prizes Everyday @ www.2vin.com, Everyone can win by answering simple questions.Earn points for referring your friends and exchange your points for cool gifts.

    ReplyDelete