with the statement
This value remains in
until we store a different value (for example, using the command
) or we clear
using the command
Once a variable is set to a particular value, we can get this value by using the variable name in an expression (e.g.
to a value of 5 using the following input to the m-file environment. In the following,
is the prompt displayed by the m-file environment:
>> d = 5
Then we could compute the circumference and assign its value to the variable
>> c = pi*d
In this command, the product of the value of
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. Variable names are case sensitive, so
are different variables.
Which of the following are valid variable names?
ecky ecky ecky ecky ptang zoo boing
There are several predefined variables. The most commonly used include
Once assigned, variable names remain until they are reassigned or eliminated by the
Variables can contain several types of numerical values. These types include the following:
Figure 1 shows a Sharp GP2D12 infrared distance sensor (http://www.acroname.com/robotics/info/articles/sharp/sharp.html) and a BasicX-24 microprocessor (http://www.basicx.com/).
The infrared distance sensor and microprocessor.
The terminal velocity reached by a sky diver depends on many factors, including their weight, their body position as they fall, and the density of the air through which they fall. The terminal velocity is given by (http://en.wikipedia.org/wiki/Terminal_velocity)
m is the sky diver's mass
g is Earth's gravitational constant
r is the atmospheric density
A is the sky diver's effective area
Cd is the sky diver's coefficient of drag
Use the following values for the other variables: