2013年5月2日 星期四

華盛頓大學-Computational Neuroscience-安裝Octave在Mac Lion

第一周的功課是要安裝好Matlab 或是 Octave

Matlab 是付費軟體, 那Octave則是媲美Matlab的opensource 軟體

這兩種都是針對數值分析做開發, 所以在矩陣運算特別強大

小女子兩袖清風, 在加上是使用MAC系統, 所以如往常選擇開源碼軟體-Octave

就來示範如何安裝Octave 在Mac OSX lion 系統下

先在Google 上Key 『Octave on mac lion』會發現找到都是舊版的

Octave 3.4.0

如果要安裝新版, 還是得乖乖去官網瞧

http://www.gnu.org/software/octave/





在右邊會看到Download , 點進去, 往下拉, 找到OSx 系統, 點入連結




會看到亂糟糟的wiki , 不用懷疑, 安裝步驟都寫在這裡

他提供三種方法安裝, 看起來Homebrew是最簡單, key幾個字就好

Homebrew

Homebrew is a package management system that simplifies the installation of software on Mac OS X. It is a free/open source software project to simplify installation of other free/open source software. It is similar in aim and function to MacPorts and Fink. It was written by Max Howell and has gained popularity in the Ruby on Rails community and earned praise for its extensibility.

Simple Installation Instructions

First, install Homebrew:
  • Install XCode via the Mac App Store.
    • Once installed, install the Command Line Tools from XCode's Apple Menu > Preferences > Downloads.
  • Follow Homebrew's installation instructions.
  • Import the scientific computing packages, including Octave:
brew tap homebrew/science
To install Octave, update to the latest package definitions, install gfortran, and then Octave:
brew update && brew upgrade
brew install gfortran
brew install octave
The command below upgrades Octave and its dependencies to the latest Homebrew-supported versions:
brew update && brew upgrade
Octave has many dependencies which will be downloaded and installed prior to Octave. The entire installation process can take a few hours.
You might find that you need to add:
setenv ("GNUTERM", "X11")
to your octaverc file, normally located at /usr/local/share/octave/site/m/startup.

第一步:先去Appstor 下載 Xcode 

不知道Appstore在哪請參圖

Xcode要下載一段時間, 大約是一小時

第二步:從Xcode >檔案>偏好>下載, 找到Command Line Tools , 大約20分鐘






第三步, 去Homebrew主頁, 下載套件, 


拉到最底端, 看到如下圖



將, 裡面文字覆至到終端機, 就會自動下載

終端機長什麼樣子, 如下





執行完成後, 




要下載最新的octave

所以將wiki程式碼貼在終端機, 先貼第一個, enter


brew tap homebrew/science



執行完後, 再貼第二個, 按enter



brew update && brew upgrade
brew install gfortran
brew install octave


再貼第三個, enter


brew update && brew upgrade


再貼第四個, enter


setenv ("GNUTERM", "X11")


大約下載安裝20分鐘

會看到 summery 下

/usr/local/share/octave/site/m/startup.

每台電腦都不同, 但看到這就已經成功了

關掉終端機


在重新打開終端機


打上octave , enter  (執行octave 程式)








就會自動跑這一串出來

這時候就可以下命令了

比如我們寫上

octave:1>a = [ 1 2; 2 1 ] , enter 輸入

就會跑出

a =
     1     2
     2     1

再寫上 octave:1> a*a  , enter 

就會跑出

ans =

     5     4
     4     5


就這樣, 在終端機上執行octave,成功!