Entering a table of numbers MathCad Help

When you enter a table of numbers, you are actually assigning elements to a vector. This section discusses how to do this using input tables and range variables. To enter an input table, enter a definition with a subscripted variable on one side and a sequence of values separated by commas on the other. For example:

• To define i to run through four values, type i: 1; 4. Note that i must take integer values only. Otherwise it can’t be used as a subscript in the next step.

• Click in a new spot and type x [i: The placeholder indicates that Mathcad is expecting a value for xl’

• Type 3 and press the comma key. Mathcad shows another placeholder to indicate that Mathcad now expects a value for x2

• Type 5, 15,20 to supply values for .” x2′ x3′ and x4

Once you have created an input table, you can do any of the following:

• Insert a value in the middle of a table. Click on the value immediately above wherever you want to insert the new value. Then type a comma. Under the selected value in the table, Mathcad creates a placeholder surrounded by a box. To enter another number, just type it into this placeholder.

• Extend the table to hold additional values. Click on the last value in the table and follow the steps above for inserting a value in the table.

• Replace or delete a value from the table. Place the value you want to replace or delete between the two editing lines and choose Cut from the Edit menu. Mathcadreplaces the value with an empty placeholder. Type a new value in this placeholder to replace the old one. To delete the value completely and decrease the array length by one in the process, backspace over the placeholder.

Some notes about input tables:

• Each value in an input table must be either a number or an expression that returns a number, the name of an array or an expression that returns an array. Expressions involving range variables and expressions created by using the Matrix command on the Insert menu are not permitted.

• All expressions in an input table must have the same climensions if any. If you want each expression to be in meters, for example, you may have to include the abbreviation for meters in each table entry. A shortcut is to enter the numbers without units and redefine the vector with units by typing something like x :=X· m/sec2 .

• An input table ordinarily has one entry for each value of the range variable used in defining it. If the table has too few entries, Mathcad will define only as many values as are present. If the table has too many entries, the extra entries will be ignored.

• Input tables assign values only to those elements specified by the range variable. If in the previous example, the range variable definition had been i := 10,20 .. 40, Mathcad would have assigned values to x 10 ‘ x20′ x30 and x40 . Mathcad would then pad the unassigned entries, namely Xo through x9′ xl1 through x19’ and so on, with zeros. You will see these zeros if you clisplay the vector by typing “x».” It is possible to inadvertently create large tables this way.

• Input tables are limited to 50 elements. If you want to enter more than 50 elements, enter them using several tables. You could, for example, define j 1 from 1 to 50 and j2 from 51 to 100, type x [j 1: followed by the first fifty numbers, then type x [ j 2 : foilowed by the second fifty numbers.

• When confronted with a very large number of data values, consider reading them in from a data file stored on your disk as an alternative to typing them in with input tables. Chapter 19, “Data Management,” cliscusses this in more detail.

Figure 11-5 shows some input tables. Note how typing x= and y= displays the elements of x and y in vector form. Mathcad ignores the last number in the input table for y since this entry would have index 5 and the range variable i stops at 4. Contrast this with typing x [i= as shown in Figure 11-3.

Note that the first element of both vectors is zero. This is because Mathcad’s array origin is set to zero by default. Since the range variable i starts at 1, the zeroth element is never explicitly defined. In the absence of an explicit definition, Mathcad assumes a value of
zero.

Posted on November 20, 2015 in Range Variables