Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hackassin
GitHub Repository: hackassin/Coursera-Machine-Learning
Path: blob/master/Week 2/Octave Tutorial/1. Basic Operations/basic_operations.txt
625 views
1
GNU Octave, version 4.4.1
2
Copyright (C) 2018 John W. Eaton and others.
3
This is free software; see the source code for copying conditions.
4
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
5
FITNESS FOR A PARTICULAR PURPOSE. For details, type 'warranty'.
6
7
Octave was configured for "x86_64-w64-mingw32".
8
9
Additional information about Octave is available at https://www.octave.org.
10
11
Please contribute if you find this software useful.
12
For more information, visit https://www.octave.org/get-involved.html
13
14
Read https://www.octave.org/bugs.html to learn how to submit bug reports.
15
For information about changes from previous versions, type 'news'.
16
17
#initializing a vector matrix
18
octave:1> A = [1 2; 3 4; 5 6];
19
octave:2> A
20
A =
21
22
1 2
23
3 4
24
5 6
25
26
octave:3> V = [1 2 3]
27
V =
28
29
1 2 3
30
31
octave:4> w = randn(1,3);
32
octave:5> w
33
w =
34
35
0.080128 0.255278 -1.002988
36
37
octave:6> w = randn(1,3)
38
w =
39
40
-1.43522 -0.29006 1.11089
41
42
octave:7> w = randn(0,3)
43
w = [](0x3)
44
octave:8> w = randn (2,3)
45
w =
46
47
-2.35972 1.25747 0.74258
48
-0.57238 2.70842 2.20403
49
50
octave:9> w = randn(1,100)
51
w =
52
53
Columns 1 through 10:
54
55
-0.493039 0.404855 1.531180 -0.273810 0.692574 -0.376706 -0.746486 0.808372 1.082853 -0.459004
56
57
Columns 11 through 20:
58
59
-1.215111 -1.287317 0.217249 1.200840 -1.005836 -2.015189 0.429838 -2.455981 -0.040263 -0.892568
60
61
Columns 21 through 30:
62
63
-0.137333 0.612469 -0.717426 -0.996906 0.140918 0.254565 -0.206344 2.369930 -1.962787 0.172451
64
65
Columns 31 through 40:
66
67
-0.358356 1.904405 -0.589134 -1.612952 -1.073178 0.705945 2.251045 -0.314819 -0.324525 0.337204
68
69
Columns 41 through 50:
70
71
-2.607428 -2.330861 0.425313 0.855031 0.438885 1.848060 0.884042 0.627392 -1.149816 1.041241
72
73
Columns 51 through 60:
74
75
-0.666072 -0.863453 0.720259 2.059668 -0.212043 -0.353723 -0.594280 0.989257 -1.228740 0.821579
76
77
Columns 61 through 70:
78
79
-2.780196 -0.581823 1.607572 -0.210835 0.425206 0.464465 3.096434 -0.654863 -1.402686 0.830433
80
81
Columns 71 through 80:
82
83
-1.070995 1.342359 2.104442 1.439956 -0.262699 -0.792237 1.313962 1.488402 1.310021 -1.179423
84
85
Columns 81 through 90:
86
87
-1.083812 -0.335519 -1.220298 1.471193 0.692455 0.291764 0.655160 0.726798 0.673464 0.909671
88
89
Columns 91 through 100:
90
91
0.652066 0.617140 0.484778 -0.332232 -0.737613 0.982260 -1.065312 0.011762 0.176341 0.598577
92
93
octave:10> hist (w)
94
octave:11> hist (w)
95
octave:12> hist (w)
96
octave:13> hist (w)
97
octave:14> x = eye (5)
98
x =
99
100
Diagonal Matrix
101
102
1 0 0 0 0
103
0 1 0 0 0
104
0 0 1 0 0
105
0 0 0 1 0
106
0 0 0 0 1
107
108
octave:15> help eye
109
'eye' is a built-in function from the file libinterp/corefcn/data.cc
110
111
-- eye (N)
112
-- eye (M, N)
113
-- eye ([M N])
114
-- eye (..., CLASS)
115
Return an identity matrix.
116
117
If invoked with a single scalar argument N, return a square NxN
118
identity matrix.
119
120
If supplied two scalar arguments (M, N), 'eye' takes them to be the
121
number of rows and columns. If given a vector with two elements,
122
'eye' uses the values of the elements as the number of rows and
123
columns, respectively. For example:
124
125
eye (3)
126
=> 1 0 0
127
0 1 0
128
0 0 1
129
130
The following expressions all produce the same result:
131
132
eye (2)
133
==
134
eye (2, 2)
135
==
136
eye (size ([1, 2; 3, 4]))
137
138
The optional argument CLASS, allows 'eye' to return an array of the
139
specified type, like
140
141
val = zeros (n,m, "uint8")
142
143
Calling 'eye' with no arguments is equivalent to calling it with an
144
argument of 1. Any negative dimensions are treated as zero. These
145
odd definitions are for compatibility with MATLAB.
146
147
See also: speye, ones, zeros.
148
149
Additional help for built-in functions and operators is
150
available in the online version of the manual. Use the command
151
'doc <topic>' to search the manual index.
152
153
Help and information about Octave is also available on the WWW
154
at https://www.octave.org and via the [email protected]
155
mailing list.
156