Octave (1.Basic Operation)

  Just study machine learning on Coursera, so we could do some exercise. 
  1. Download Octave from Octave
  2. Install the Octave
  3. Use Octave to do some simple calculation
 Simple calculation:
1 + 2
2 - 1
3 * 2
5 / 8
2^6
1 == 2     % false = 0
1 ~= 2     % true = 1
1 && 0     % AND
1 || 0      % OR
xor(1,0)    % ans = 1
PS1('>> ')    % just show ">>" 
 
Variable:
a = 3
a = 3;    % semicolon suppress the output
b = 'hi';
b    % output b = hi

a = pi;
a    % output "a = 3.1416"
disp(a)    % output "a = 3.1416"
disp(sprintf('2 decimals: %0.2f', a))    % output "2 decimals: 3.14"

format long
a     % a = 3.14159265358979

format short
a    % a = 3.1416
 
Matrix and vector:
A = [1 2; 3 4; 5 6]
v = [1; 2; 3]

v = 1:0.1:2
v = 1:6

w = ones(2,3)
w = rand(1,3)
randn(1,10000)    % Guassian
hist(w)    % histogram

I = eye(4)

help eye/rand/help
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值