※こちらは旧サイトです(新サイトはこちら

Debianでoctaveとgnuplotを使ってみる

2016-06-21 19:17:16

Andrew Ng教授のMachine Learningコースを受講してて、紹介されてたOctaveをインストールしてみた時のメモ

公式Wikiを見てOctaveをインストール

Octave for Debian systemsを見て色々インストール

$ sudo apt-get install octave octave-control octave-image octave-io octave-optim octave-signal octave-statistics

$ octave -v
GNU Octave, version 3.8.2
Copyright (C) 2014 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.

Octave was configured for "x86_64-pc-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/get-involved.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.

CUIで使ってみる

$ octave

octave:1> 1+1
ans =  2
octave:2> 1+2
ans =  3
octave:3> 1*2*3*4*5
ans =  120
octave:4> quit

GUIを起動するには

--force-guiオプションをつけて起動する

$ octave --force-gui

Gnuplotをインストール

Octaveでグラフ描画するには、Gnuplotが必要なのでインストールする

$ sudo apt-get install gnuplot

$ gnuplot --version
gnuplot 4.6 patchlevel 6

プロットしてみる

GUIを起動し、プロットしてみる

>> x=-5:5;
>> y=2*x;
>> plot(x,y)

とてもエラー

libGL error: pci id for fd 17: 80ee:beef, driver (null)
OpenGL Warning: glFlushVertexArrayRangeNV not found in mesa table
OpenGL Warning: glVertexArrayRangeNV not found in mesa table
OpenGL Warning: glCombinerInputNV not found in mesa table
OpenGL Warning: glCombinerOutputNV not found in mesa table
OpenGL Warning: glCombinerParameterfNV not found in mesa table
OpenGL Warning: glCombinerParameterfvNV not found in mesa table
OpenGL Warning: glCombinerParameteriNV not found in mesa table
OpenGL Warning: glCombinerParameterivNV not found in mesa table
OpenGL Warning: glFinalCombinerInputNV not found in mesa table
OpenGL Warning: glGetCombinerInputParameterfvNV not found in mesa table
OpenGL Warning: glGetCombinerInputParameterivNV not found in mesa table
OpenGL Warning: glGetCombinerOutputParameterfvNV not found in mesa table
OpenGL Warning: glGetCombinerOutputParameterivNV not found in mesa table
OpenGL Warning: glGetFinalCombinerInputParameterfvNV not found in mesa table
OpenGL Warning: glGetFinalCombinerInputParameterivNV not found in mesa table
OpenGL Warning: glDeleteFencesNV not found in mesa table
OpenGL Warning: glFinishFenceNV not found in mesa table
OpenGL Warning: glGenFencesNV not found in mesa table
OpenGL Warning: glGetFenceivNV not found in mesa table
OpenGL Warning: glIsFenceNV not found in mesa table
OpenGL Warning: glSetFenceNV not found in mesa table
OpenGL Warning: glTestFenceNV not found in mesa table
libGL error: core dri or dri2 extension not found
libGL error: failed to load driver: vboxvideo
OpenGL Warning: No pincher, please call crStateSetCurrentPointers() in your SPU
>>

デフォルトではFLTKになっている

FLTKがデフォルトのプロットユーティリティになっているため、これをGnuplotに変更する必要がある。

手動で変更するには以下をoctave上で実行。

>> graphics_toolkit("gnuplot");

プロットしてみる(2回目)

>> x=-5:5;
>> y=2*x;
>> plot(x,y)

デフォルトでGnuplotに変更する

~/.octavercに記述しておく

$ vim ~/.octaverc

graphics_toolkit("gnuplot");