Como diz a sua descrição no ebuild -> GNU Octave is a high-level language (MatLab compatible) intended for numerical computations
Aqui voces tem um excelente centro de calculo cientifico.
Para instalar o octave basta fazer
Code: Select all
emerge octave gnuplotO octave pode-se usar tal como a consola do python porque e' tambem uma linguagem interpretada.
Lição 1 conceitos basicos.
Vamos para a linha de comandos e basta escrever
Code: Select all
$ octaveCode: Select all
GNU Octave, version 2.1.73 (x86_64-pc-linux-gnu).
Copyright (C) 2006 John W. Eaton.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or
FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.
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/help-wanted.html
Report bugs to <bug@octave.org> (but first, please read
http://www.octave.org/bugs.html to learn how to write a helpful report).
octave:1>Code: Select all
octave:1> disp ('Ola Mundo')
Ola MundoO octave é uma poderosa ferramenta de calculo então vamos calcular o sin(x) em 100 pontos de -20 a 20.
Para tal basta:
Code: Select all
octave:1>y = linspace (-20,20,100);
octave:2> x = sin(y);
octave:3> plot (x)Agora experimentem a tirar o ';' para ver o que acontece.
Para colocar mais do que um gráfico pode-se usar o comando 'hold on'
Code: Select all
octave:1>y = linspace (-20,20,100);
octave:2>x = sin(y);
octave:3>z = cos(y);
octave:4>plot (x);
octave:5>hold on
octave:6>plot(z);O comando 'close all' fecha todos os programas externos que funcionam directamente com o octave como por exemplo um grafico aberto com o gnuplot.
Recomendo o uso de um editor de texto como o vim ou gvim que possuem syntax highlight para matlab/octave ou emacs que possui um modo de matlab/octave disponivel no portage.
Agora vamos ver como podemos usar o octave para fazer calculos basicos.
Code: Select all
octave:39> 1.3^32 * 5.4^-12
ans = 7.2021e-06m= 9.1*10^-31 Kg (massa aproximada do electrão)
c=2.998^8 m/s (velocidade da luz aproximada)
Code: Select all
octave:43> m = 9.1*10^-31
m = 9.1000e-31
octave:44> c = 2.998 * 10^8
c = 299800000
octave:45> E = m * c^2
E = 8.1791e-14Agora vamos estudar Matrizes.
Code: Select all
octave:50> a = [1 2 3 4 5]
a =
1 2 3 4 5
octave:51> b = [6 7 8 9 10]'
b =
6
7
8
9
10
octave:52> a*b
ans = 130Agora mais um problema
Code: Select all
octave:59> a = [1 2 3 4 5]
a =
1 2 3 4 5
octave:60> b = [6 7 8 9 10]
b =
6 7 8 9 10
octave:61> a*b
error: operator *: nonconformant arguments (op1 is 1x5, op2 is 1x5)
error: evaluating binary operator `*' near line 61, column 2
octave:61> a.*b
ans =
6 14 24 36 50Mas se incluirmos o operador '.' forçamos o octave a multiplicar as matrizes cujo as dimensões não são coerentes.
O octave pode interagir com o sistema operativo no qual podes correr os comandos:
Code: Select all
octave:71> pwd
/home/metalgod
octave:72> ls
(mostra os ficheiros dessa directoria)
octave:73> unix ('uname -a')
Linux darksytem 2.6.17-gentoo-r3 #3 PREEMPT Tue Jul 25 20:20:06 WEST 2006 x86_64 AMD Athlon(tm) 64 Processor 3500+ AuthenticAMD GNU/Linux
ans = 0Code: Select all
octave:1> quit
metalgod@darksytem ~ $

