Octave 在mac上的安装使用

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))

然后结果就是这个:


如果用meshc就得到contour plot
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容