day1/cheatsheet2.tex
author Shantanu <shantanu@fossee.in>
Tue, 10 Nov 2009 12:21:29 +0530
changeset 294 f05b1c457120
parent 291 ec70a2048871
child 300 f87f2a310abe
permissions -rw-r--r--
Added exercise session day1.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
284
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     1
\documentclass[12pt]{article}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     2
%\title{Plotting Data}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     3
%\author{FOSSEE}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     4
\begin{document}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     5
\date{}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     6
\vspace{-1in}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     7
\begin{center}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     8
\LARGE{Plotting Data}\\
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
     9
\large{FOSSEE}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    10
\end{center}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    11
\section{Plotting from Data files}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    12
\begin{verbatim}
291
ec70a2048871 Updated cheatsheet for session 2.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 284
diff changeset
    13
l = [] #Empty List
ec70a2048871 Updated cheatsheet for session 2.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 284
diff changeset
    14
t = []
ec70a2048871 Updated cheatsheet for session 2.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 284
diff changeset
    15
for line in open('pendulum.txt'): # Opening & Reading files
ec70a2048871 Updated cheatsheet for session 2.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 284
diff changeset
    16
    points = line.split() # Splitting a string
ec70a2048871 Updated cheatsheet for session 2.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 284
diff changeset
    17
    l.append(float(points[0])) # Appending to a list
ec70a2048871 Updated cheatsheet for session 2.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 284
diff changeset
    18
    t.append(float(points[1]))
ec70a2048871 Updated cheatsheet for session 2.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 284
diff changeset
    19
tsq = []
ec70a2048871 Updated cheatsheet for session 2.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 284
diff changeset
    20
for time in t:  #Iterating through lists
ec70a2048871 Updated cheatsheet for session 2.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 284
diff changeset
    21
    tsq.append(t*t)
ec70a2048871 Updated cheatsheet for session 2.
Santosh G. Vattam <vattam.santosh@gmail.com>
parents: 284
diff changeset
    22
plot(l, tsq, '.') # Plotting points
284
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    23
\end{verbatim}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    24
\end{document}
3c191accbb32 Added Cheatsheets for day1.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff changeset
    25