You are on page 1of 3

MET 107 Graphing Array Elements - Pages 1 & 2

Summing Array Elements - Page 3

Graphing data stored in arrays

Assume the following set of ordered pairs that need to be plotted, similar to an x/y scatter graph in
Excel:

2 1
DataMatrix :=
3 .5
4.75 2.3
5.25
1.5

Pull data from each column of the array using the Matrix Column tool M<> (ctrl-6)
Remember, the default for array starting locations in Mathcad is 0
0
X := DataMatrix

1
Y := DataMatrix

2 1
X=
3
Y=
0.5
Check the values
4.75 2.3
5.25 1.5

2.5

2
Quick Plot
Y 1.5

0.5
2 3 4 5 6
X

Graphing_Summing_Arrays
Clean this graph up a bit by automatically setting the Axis limits

minx := min( X) = 2
minx := floor( minx) = 2

maxx := max( X) = 5.25


maxx := ceil( maxx) = 6

miny := min( Y) = 0.5


miny := floor( miny) = 0

maxy := max( Y) = 2.3


maxy := ceil( maxy) = 3

2
Y
1

0
2 3 4 5 6
X

2 2.5

3 1.5

A := 3.5 .75
4 1.5

5.25 2.5

2.5
Note that you can plot directly from the
2 2-D array
Y
1 1.5
A
1

0.5
2 3 4 5 6
0
X, A

Graphing_Summing_Arrays
Summing Array Elements:
ORIGIN := 1
7

6
5
C := 4
Double check values in select locations
3
2
1 C =6 C =5 C =4 C =3
2 3 4 5

5
sum :=
C
j
Sum up elements in location 2 through 5 inclusive
This tool is found in the Calculus toolbar
j=2

sum = 18

check := C + C + C + C
2 3 4 5

check = 18

Note: Can not do this directly with functions as summing elements of functions defined
with range variables does not really sum the elements themselves (if the range value does
not increment by 1).
Example:
2
f ( q ) := q + 9 Define a function

q := 0 , .5 .. 3 Evaluate the function in increments not equaling 1


Note the .5 increment!
f (q) =
9
f (3) = 0 This is a function!
8.75
8
6.75 1 f = There is no value stored
3


at the third location as this is
5 f ( q ) = 17
not an array.
2.75 q= 0
0
The above actually a sum of f(0) and f(1) f (0) = 9
f (1) = 8

Graphing_Summing_Arrays

You might also like