I followed these instructions because I couldn't find any for 14.04 ubuntu.
http://www.schoeps.org/home/2015/06/five-simple-instructions-to-compile-octave-4-on-ubuntu/
# 1) get necessary dev-tools
sudo apt-get install g++ gcc gfortran make autoconf automake bison flex gperf
gzip icoutils librsvg2-bin libtool perl rsync tar
# 2) get necessary packages
sudo apt-get install libblas-dev liblapack-dev libpcre3-dev libarpack2-dev
libcurl4-gnutls-dev epstool libfftw3-dev transfig libfltk1.3-dev
libfontconfig1-dev libfreetype6-dev libgl2ps-dev libglpk-dev libreadline-dev
gnuplot libgraphicsmagick++-dev libhdf5-serial-dev openjdk-7-jdk
libsndfile1-dev llvm-dev lpr texinfo libgl1-mesa-dev libosmesa6-dev pstoedit
portaudio19-dev libqhull-dev libqrupdate-dev libqscintilla2-dev libqt4-dev
libqtcore4 libqtwebkit4 libqt4-network libqtgui4 libsuitesparse-dev libxft-dev
zlib1g-dev
# 3) download and extract
cd /tmp
wget -cftp://ftp.gnu.org/gnu/octave/octave-4.0.0.tar.gz
tar -xzf octave-4.0.0.tar.gz
cd octave-4.0.0
# 4) configure and make
./configure --prefix=/opt/octave-4.0.0 CPPFLAGS=-I/usr/include/hdf5/serial
LDFLAGS=-L/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/hdf5/serial
make
make check
# 5) install
sudo make install
I tried this but get an error when I run #2 I try and configure but I
get an error
The following packages have unmet dependencies:
libosmesa6-dev : Depends: libosmesa6 (= 10.1.3-0ubuntu0.4) but it is
not going to be installed
E: Unable to correct problems, you have held broken packages.
And
configure: error: to build Octave, you must have the PCRE library and
header files installed