octave-basic
在coursera上斯坦福的machine learning,lecturer极力推荐开源的编程环境Octave入手,所以我也下载了来试一试吧==
参考链接:http://www.linuxdiyf.com/linux/22034.html
安装(Ubuntu16.04):我看了下官网,Ubuntu上已经更新到4.0.3了,不过还是选了stable的,这里应该是4.0.2
$ sudo apt-add-repository ppa:octave/stable
$ sudo apt-get update
$ sudo apt-get install octave
运行octave:有图形界面 $ sudo octave
或者使用命令行来运行:$ sudo octave-cli
Octave和Matlab的主要区别:
1、费用方面
Octave是完全免费的(并且是开源的),而Matlab是商业软件
2、占用空间
Octave比较小,安装程序只有几十兆;Matlab庞大,是因为有大量的面向各种应用领域的工具箱,Octave无法相比的。
3、语法方面
Octave最初便是模彷Matlab而设计,语法基本上与Matlab一致,严谨编写的代码应同时可在Matlab及Octave运行,但也有很多细节上差别。
所以真的要写可以在matlab上运行的octave的话,需要考虑兼容性。
4、绘图方面
Octave的画图后台是强大的Gnuplot,有人认为绝对不会弱于Matlab,而且输出格式要远多于Matlab,公式显示也要强大很多。但也有人说Octave绘图速度比Matlab慢。
5、用户界面
Octave的GUI才刚开始有,可能弱一些。
Octave操作
% one row
x1 = [1, 3, 2]
% three row
x2 = [1; 3; 2]
% complex matrix should use .' for transposition
A.'
% A and B are matrix. Element-wise.
% .* ./ .^
A ./ B
a = 5
% Cij = a^Bij
C = a .^ B
% Moreover, we can also calculate row-wise multiply or division:
a = [1 2 3; 4 5 6; 7 8 9]
b = [10; 11; 12]
c = b.*a
d = a./b
index:
和Matlab一样,下标从1开始。
x = [1.2, 5, 7.6, 3, 8]
x(2)
% use index list
x([1, 3, 4])
A = [1, 2, 3; 4, 5, 6; 7, 8, 9]
% 1st and 3rd rows and 2nd and 3rd cols
A([1, 3], [2, 3])
% : means all elements
A(2, :)
range:
% start:step:stop
% default step is 1
1:3:10
% end means last element in the row or col. For vector and matrix
% last col of A showing
A(:, end)
special matrix:
x = [1,2,3;4,5,6;7,8,9]
% lower triangular part of x. Diagonal included.
tril(x)
% upper triangular part of x. Diagonal included.
triu(x)
% indentity matrix. eye(m, n) for m*n. filled by '0'
eye(n)
ones(m, n)
zeros(m, n)
% elements are in [0,1). uniformly drawn
rand(m, n)
% normaly distributed. negative is ok
randn(m, n)
% return a random permutation which is a row vector
randperm(n)
v = [1,2,3]
% diagonal are from v. other places are '0'
diag(v)
% return a vector contain elements from diagnoal of x
diag(x) % n elements in [a, b]. avg. n, is optional with default value 100.
linspace(a, b, n)
% n elements in [10^a, 10^b]. n is optional with default value of 50
logspace(a, b, n)
% left-right exchange
fliplr(x)
% up and down exchange
flipud(x)
% returns a copy of matrix A that has been rotated by (90n)° counterclockwise
rot90(x, n)
% sort and in increasing order
sort(x)
% rearrange x to m*n matrix. Selection start from x11 to xm1, then x21 to xm2....
reshape(x, 2, 6)
octave-basic的更多相关文章
- CheeseZH: Octave basic commands
1.Basic Operations 5+6 3-2 5*8 1/2 2^6 1 == 2 %false ans = 0 1 ~= 2 %true ans = 1 1 && 0 %AN ...
- Octave入门
Octave/Matlab Tutorial Octave/Matlab Tutorial Basic Operations 你现在已经掌握不少机器学习知识了 在这段视频中 我将教你一种编程语言 Oc ...
- 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 5 Octave Tutorial
Lecture 5 Octave教程 5.1 基本操作 Basic Operations 5.2 移动数据 Moving Data Around 5.3 计算数据 Computing on Data ...
- Octave教程
Windows安装Octave http://wiki.octave.org/Octave_for_Microsoft_Windows 基本操作(Basic Operations) octave:1& ...
- Atitit HTTP 认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结
Atitit HTTP认证机制基本验证 (Basic Authentication) 和摘要验证 (Digest Authentication)attilax总结 1.1. 最广泛使用的是基本验证 ( ...
- Basic Tutorials of Redis(9) -First Edition RedisHelper
After learning the basic opreation of Redis,we should take some time to summarize the usage. And I w ...
- Basic Tutorials of Redis(8) -Transaction
Data play an important part in our project,how can we ensure correctness of the data and prevent the ...
- Basic Tutorials of Redis(7) -Publish and Subscribe
This post is mainly about the publishment and subscription in Redis.I think you may subscribe some o ...
- Basic Tutorials of Redis(6) - List
Redis's List is different from C#'s List,but similar with C#'s LinkedList.Sometimes I confuse with t ...
- Basic Tutorials of Redis(5) - Sorted Set
The last post is mainly about the unsorted set,in this post I will show you the sorted set playing a ...
随机推荐
- jquery阻止网页中右键的点击
<body onmousedown="whichElement(event)"> </body> function whichElement(e) { if ...
- BigDecimal的加减乘除
Java在java.math包中提供的API类BigDecimal,用来对超过16位有效位的数进行精确的运算.双精度浮点型变量double可以处理16位有效数.在实际应用中,需要对更大或者更小的数进行 ...
- Kendo MVVM 数据绑定(十一) Value
Kendo MVVM 数据绑定(十一) Value Value 绑定可以把 ViewModel 的某个属性绑定到 DOM 元素或某个 UI 组件的 Value 属性.当用户修改 DOM 元素或 UI ...
- 零基础逆向工程18_PE结构02_联合体_节表_PE加载过程
联合体 特点 1.联合体的成员是共享内存空间的 2.联合体的内存空间大小是联合体成员中对内存空间大小要求最大的空间大小 3.联合体最多只有一个成员有效 节表数据结构说明 PE 加载 过程 FileBu ...
- Json字符串与js数组互相转换
1.Json数据格式的字符串转换成js数组: JSON.parse(str); // str 字符串格式 2.js数组转换成Json数据格式字符串: var myJSONText = JSON.s ...
- npm在linux即mac下更新时报错
nam在linux即mac下需要更新到新版本:
- 程序员的智囊库系列之2----网站框架(framework)
程序员的智囊库系列之2--网站框架(framework) 这是程序员的智囊库系列的第二篇文章.上一篇文章讲了服务器与运维相关的工具,这篇文章我们将介绍几个搭建网站的框架: django express ...
- AE开发关于OnMapReplaced方法的使用原理
The OnMapReplaced event is triggered whenever the IMapControl2::Map is replaced by another map, such ...
- Uva 10635 Prince and Princess (LCS变形LIS)
直接LCS是时间复杂度是O(p*q)的,但是序列元素各不相同,只要把其中一个序列映射成有序的, 另外一个序列再做相同的映射,没有的直接删掉,就变成了求另一个序列LIS. #include<bit ...
- UVALive 3523 Knights of the Round Table 圆桌骑士 (无向图点双连通分量)
由于互相憎恨的骑士不能相邻,把可以相邻的骑士连上无向边,会议要求是奇数,问题就是求不在任意一个简单奇圈上的结点个数. 如果不是二分图,一定存在一个奇圈,同一个双连通分量中其它点一定可以加入奇圈.很明显 ...