The Student's Introduction to MATHEMATICA: A Handbook for Precalculus, Calculus, and Linear Algebra

3.11: Managing Data An Introduction to Lists

3.11 Managing Data An Introduction to Lists

You will often need to modify or transform the data with which you started. For instance, you might begin with a large table of data and wish only to work with a few rows or columns of it. Or you might wish to transform a particular row or column in a large table of data by applying the natural logarithm to each item in that row or column. In this section we introduce a few techniques to help with such tasks.

We mentioned in Section 3.5 that a list in Mathematica is a collection of items separated by commas and enclosed in curly brackets, such as {2, 5, 9, 7, 4}. Our first task will be to master the art of extracting one or more items from a list.

  In[1]:= <b class="bold">myList = Table[2</b><sup<b class="bold">k</b></sup><b class="bold">, {k, 10}]</b>Out[1]= {2, 4, 8, 16, 32, 64, 128, 256, 512, 1024}  In[2]:= <b class="bold">myList[[5]]</b>Out[2]= 32

If you type the name of a list followed by [[5]], you will extract the fifth part of the list. You can also use the button on the BasicMathInput palette (in the lower right portion of the top half of the palette) to produce , which has the same meaning. One may also type from the keyboard [[ and ]] to produce the double square bracket symbols and , which also have the same meaning.

<span class="inlinemediaobject"><img alt="Image from book"> border="0">

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Waveplates and Retardation Plates
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.