Вы находитесь на странице: 1из 4

GETTING STARTED PRIMERS

Defining Variables

Often you need to define a value as a variable to use in subsequent calculations. This worksheet lets you practice defining and viewing single-value and range variables.
Practice Defining a Single-Value Variable Type:
x:2

See:

x := 2

Try it!

Type:
dist:25m

See:

dist := 25m

Try it!

Note: Here, m is a unit, not a variable. Mathcad recognizes some letters as abbreviations for units, so it added the implied multiply for you. To insert other units you must first type * for multiply. To find the abbreviation for a unit, select Unit from the Insert menu and browse for the units you want.
Type:
v.1:20mi/hr

See:

v1 := 20

mi hr

Try it!

Tip: This definition uses a literal subscript, which is part of the name of the variable. To use a literal subscript press the period [ .] key after the variable name.
See:

Click on the variable with a literal subscript above (v1) and see that the math editing lines select the whole variable name.

Defining Variables

Notice that when you type the colon [:] key or press the assignment operator key

on the Calculator toolbar, Mathcad displays :=. The assignment operator (colon equals) in Mathcad is used for definitions, or let equals.
Defining a Range Variable

Before starting these exercises, display the Matrix toolbar on your desktop by selecting Toolbars > Matrix from the View menu in the Worksheet window. Remember that to use a toolbar with the Resources window, you must move the toolbar to the far left in your Worksheet window. Then bring your Resources window back up to make it the "active" window and position it next to the Worksheet window. With your Matrix toolbar in view and your Resources window active:
Type:
b: 1 [Tab] 10

See:

b := 1 .. 10 Tip: You get a range of numbers between 1 and 10 at whole number increments.
See:

Try it!

Type:
k:3.5;12.5

k := 3.5 .. 12.5 Tip: You get a range of numbers between 3.5 and 12.5 at whole number increments.

Notice that when you type the semicolon character [;], it displays on the screen as two dots ( .. ) surrounded by placeholders. This is Mathcad's range variable operator. Try it!
Type:
d:3.5,4.0;12.5

See:

Try it!

d := 3.5 , 4 .. 12.5 Tip: You get a range of numbers between 3.5 and 12.5 in increments of 0.5.

Type:

See:
Defining Variables 2

q:1/4 [Spacebar] ,1/2 [Spacebar] ;7/4

q :=

1 1 7 , .. 4 2 4

Try it!

Tip: You get a range of numbers 1 7 1 between and in increments of 4 4 4 .


See:

Type:
n:-6,-5.9;6

n := 6 , 5.9 .. 6 Tip: You get a range of numbers between -6 and 6 in increments of 0.1.

Try it!
Viewing a Definition Type:
x.start:45ft

See:

xstart := 45ft

Try it!
Type:
x.start=

See:

xstart = 13.716 m Tip: Units are always displayed in the base units of the worksheet. Here the result is given in SI, the default unit system in Mathcad. You can change the default units in Worksheet Options under the Tools menu.

Try it!

If you want your range to be in increments other than 1 (the default), enter the next value in the range after the first one. For example, to create a range variable x that goes from 2 to 8 in increments of 0.5, type:
Type:
t:2,2.5;8

See:

t := 2 , 2.5 .. 8

Try it!

Type:

See:

Tip: Range variables


Defining Variables 3

t=

t =
2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8

: Range variables are always displayed in a table.

Try it!

Type:
times:1s,2.5s;7s

See:

times := 1s , 2.5s .. 7s

Try it!
Type:
times=

See:

times = 1 s
2.5 4 5.5 7

Try it!

Tip: In a range variable, the difference between the starting point and the ending point should be evenly divisible by the increment you have chosen.

Note: The s next to the table above represents the unit seconds. If you click in the equation, you see a hidden multiply between the table and the s. To practice calculating results based on variables you have defined in the worksheet, continue to the second part of this primer, Calculating with Variables.

Defining Variables

Вам также может понравиться