Octave 在mac上的安装使用
2019-03-23 本文已影响0人
realnickman
octave不多说,替代matlab的免费开源神器. 安装如下:
首先看下自己是否有安装xcode:
xcode-select -v
如没有安装就装:
xcode-select --install
然后更新下brew后安装octave:
brew update
brew install octave
装完之后就可以octave开心做实验啦!
绘图上自带的gui(基于qt)非常瞎(GUI本身也很瞎,各种假死和bug),最好用gnuplot. 那么怎么修改配置呢?可以先在octave的shell里用pathdef去locate到相关路径,比如找到
/usr/local/Cellar/octave/4.4.1_6/share/octave/4.4.1/m下的startup这个folder,里面的octaverc是默认环境配置的文件,用editor打开之后加入下面两行代码:
setenv('GNUTERM','qt')
graphics_toolkit("gnuplot")
然后就可以用gnuplot来plot啦!
测试用下面的代码plot个3D grid:
% comment: Putting a semicolon at the end of line of Matlab/Octave code prevents the console from printing the answer/variable assignment/whatever.
x=linspace(-2,2,5);
y=linspace(-2,2,5);
[xx,yy]=meshgrid(x,y);
mesh(xx,yy,4-(xx.^2+yy.^2))
然后结果就是这个:
