目录

菠萝🍍的博客

有谁不喜欢吃菠萝呢

X

吴恩达机器学习5-1(octave基本操作)

显示

disp(a)
disp(sprintf('2 decimal:%0.2f',a))

赋值一个矩阵

>>  a = [1 2;3 4;5 6]
a =

   1   2
   3   4
   5   6
>> a = [1 3;
4 5;
6 7;]
a =

   1   3
   4   5
   6   7

>>

创建一个行向量 1x3

a = [1 2 3]

创建一个1-2,步率为0.1 的行向量1x11

>> v = 1:0.1:2
v =

 Columns 1 through 3:

    1.000000000000000    1.100000000000000    1.200000000000000

 Columns 4 through 6:

    1.300000000000000    1.400000000000000    1.500000000000000

 Columns 7 through 9:

    1.600000000000000    1.700000000000000    1.800000000000000

 Columns 10 and 11:

    1.900000000000000    2.000000000000000

创建一个列向量 3x1

>> a = [1;
2;
3;]
a =

   1
   2
   3

>>

创建一个2x3都为1的矩阵

>> ones(2,3)
ans =

   1   1   1
   1   1   1

>>

创建一个2x3都为2的矩阵

>> c = 2*ones(2,3)
c =

   2   2   2
   2   2   2

>>

生成零矩阵

>> zeros(5,3)
ans =

   0   0   0
   0   0   0
   0   0   0
   0   0   0
   0   0   0

生成随机值矩阵

>> rand(2,3)
ans =

   4.217561713195667e-01   9.834717266977976e-01   5.363337697224921e-01
   2.508389749723528e-01   3.739405540199602e-01   8.304582722954202e-01

>>

生成服从高斯分布的矩阵,标准差或者方差为1

>> randn(1,3)
ans =

  -5.496949005147392e-01  -9.804212148170880e-01   1.192527701401072e+00

>>

图形化生成数值分布

hist(w)

生成单位矩阵

>> eye(4)
ans =

Diagonal Matrix

   1   0   0   0
   0   1   0   0
   0   0   1   0
   0   0   0   1

>>

标题:吴恩达机器学习5-1(octave基本操作)
作者:MingGH
地址:https://runnable.run/articles/2021/06/06/1622991233481.html