day1/session5.tex
changeset 262 9664eddee075
parent 261 9cce24d00957
parent 260 1f5fea506927
child 263 8a4a1e5aec85
equal deleted inserted replaced
261:9cce24d00957 262:9664eddee075
   132   \begin{itemize}
   132   \begin{itemize}
   133   \item Load data from a text file.
   133   \item Load data from a text file.
   134   \item Each row must have same number of values.
   134   \item Each row must have same number of values.
   135   \end{itemize}
   135   \end{itemize}
   136 \begin{lstlisting}
   136 \begin{lstlisting}
   137 In []: data = loadtxt('pendulum.txt')
   137 In []: L, T = loadtxt('pendulum.txt', 
   138 In []: L = data[:,0]
   138                        unpack = True)
   139 In []: T = data[:,1]
       
   140 \end{lstlisting}
   139 \end{lstlisting}
   141 \end{frame}
   140 \end{frame}
   142 
   141 
   143 %% \begin{frame}[fragile]
   142 %% \begin{frame}[fragile]
   144 %%   \frametitle{\typ{loadtxt}}
   143 %%   \frametitle{\typ{loadtxt}}
   152   \item It contains x,y position of particle.
   151   \item It contains x,y position of particle.
   153   \item Plot the given points.
   152   \item Plot the given points.
   154 %%  \item Interpolate the missing region.
   153 %%  \item Interpolate the missing region.
   155 \end{itemize}
   154 \end{itemize}
   156 \begin{lstlisting}
   155 \begin{lstlisting}
   157 In []: data = loadtxt('points.txt')
   156 In []: x, y = loadtxt('points.txt',
   158 In []: data.shape
   157                        unpack = True)
   159 Out[]: (40, 2)
       
   160 In []: x = data[:,0]
       
   161 In []: y = data[:,1]
       
   162 In []: plot(x, y, '.')
   158 In []: plot(x, y, '.')
   163 \end{lstlisting}
   159 \end{lstlisting}
   164 \end{frame}
   160 \end{frame}
   165 
   161 
   166 \begin{frame}
   162 \begin{frame}