lekaha's blog Change the world     Wiki     Blog     Feed

Write Octave in IPython

Some of my code writen in Octave, also I would like to put it on the blog. One of easy ways is using ipython notebook with Octave then convert it to markdown content.

I am not going to use oct2py that will be a extension to ipython. It’s not my object. I would like to use pure Octave code and see highlight of Octave.

Octave

Install

  • Official download page.
  • Or directly download the Octave binary package from Octave Forge and install

Configure

Put the binary path in your PATH enviornment variable. In Mac and Octave version 3.8.0:

echo "export PATH=$PATH:/usr/local/octave/3.8.0/bin" >> ~/.bash_profile

Octave kernel

A Jupyter kernel for Octave - Github

Install

pip install octave_kernel
python -m octave_kernel.install

The secend command is important!

Check it is in the kenrnel list

ipython kernelspec list

Write a sample Octave in IPython

If you seen there is a octave in kernel list that means you are successful. Let’s try it!

ipython console --kernel octave
In[1]: fprintf('Hello octave\n');
gnuplot 4.6 patchlevel 4
Hello octave
comments powered by Disqus