Mathematica でリストを操作する
Table関数を用いると,データのリストを容易に認識可能なパターンにすることができます.一旦データをリストにしたら,後はMathematica のその他の関数を使って簡単にデータ操作ができます.
簡単な例
次の例ではsin(x)を0から6πまでπ/2の間隔で評価したリストを作成します.
![[Graphics:Images/index2_gr_63.gif]](http://library.wolfram.com/howtos/lists/Images/index2_gr_63.gif)
![[Graphics:Images/index2_gr_64.gif]](http://library.wolfram.com/howtos/lists/Images/index2_gr_64.gif)
2次元のリストも作ることができます.これで,順序対の記録を残すことができます.
![[Graphics:Images/index2_gr_65.gif]](http://library.wolfram.com/howtos/lists/Images/index2_gr_65.gif)
![[Graphics:Images/index2_gr_66.gif]](http://library.wolfram.com/howtos/lists/Images/index2_gr_66.gif)
リストのフォーマット
このリストを表として見るためにはTableFormコマンドを使います.この例では,% は直前の評価結果を意味します.
![[Graphics:Images/index2_gr_67.gif]](http://library.wolfram.com/howtos/lists/Images/index2_gr_67.gif)
結果の抽出
作成したリストから情報を抽出したり,リストの一部分を指定したりする方法はたくさんあります.次に挙げるのはExtractとPartコマンドを使った例です.
![[Graphics:Images/index2_gr_72.gif]](http://library.wolfram.com/howtos/lists/Images/index2_gr_72.gif)
![[Graphics:Images/index2_gr_73.gif]](http://library.wolfram.com/howtos/lists/Images/index2_gr_73.gif)
![[Graphics:Images/index2_gr_74.gif]](http://library.wolfram.com/howtos/lists/Images/index2_gr_74.gif)
![[Graphics:Images/index2_gr_75.gif]](http://library.wolfram.com/howtos/lists/Images/index2_gr_75.gif)
Part関数を指定する方法は2つあります.下記の例ではその両方が示されています.
![[Graphics:Images/index2_gr_76.gif]](http://library.wolfram.com/howtos/lists/Images/index2_gr_76.gif)
![[Graphics:Images/index2_gr_77.gif]](http://library.wolfram.com/howtos/lists/Images/index2_gr_77.gif)
|