Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hackassin
GitHub Repository: hackassin/Coursera-Machine-Learning
Path: blob/master/Week 2/Octave Tutorial/4. Plotting Data/plotting_data.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
octave:1> t = [0:0.01:0.98]
18
t =
19
20
Columns 1 through 11:
21
22
0.00000 0.01000 0.02000 0.03000 0.04000 0.05000 0.06000 0.07000 0.08000 0.09000 0.10000
23
24
Columns 12 through 22:
25
26
0.11000 0.12000 0.13000 0.14000 0.15000 0.16000 0.17000 0.18000 0.19000 0.20000 0.21000
27
28
Columns 23 through 33:
29
30
0.22000 0.23000 0.24000 0.25000 0.26000 0.27000 0.28000 0.29000 0.30000 0.31000 0.32000
31
32
Columns 34 through 44:
33
34
0.33000 0.34000 0.35000 0.36000 0.37000 0.38000 0.39000 0.40000 0.41000 0.42000 0.43000
35
36
Columns 45 through 55:
37
38
0.44000 0.45000 0.46000 0.47000 0.48000 0.49000 0.50000 0.51000 0.52000 0.53000 0.54000
39
40
Columns 56 through 66:
41
42
0.55000 0.56000 0.57000 0.58000 0.59000 0.60000 0.61000 0.62000 0.63000 0.64000 0.65000
43
44
Columns 67 through 77:
45
46
0.66000 0.67000 0.68000 0.69000 0.70000 0.71000 0.72000 0.73000 0.74000 0.75000 0.76000
47
48
Columns 78 through 88:
49
50
0.77000 0.78000 0.79000 0.80000 0.81000 0.82000 0.83000 0.84000 0.85000 0.86000 0.87000
51
52
Columns 89 through 99:
53
54
0.88000 0.89000 0.90000 0.91000 0.92000 0.93000 0.94000 0.95000 0.96000 0.97000 0.98000
55
56
octave:2> y1 = sin(2*pi*4t)
57
parse error:
58
59
syntax error
60
61
>>> y1 = sin(2*pi*4t)
62
^
63
64
octave:2> y1 = sin(2*pi*4*t)
65
y1 =
66
67
Columns 1 through 11:
68
69
0.00000 0.24869 0.48175 0.68455 0.84433 0.95106 0.99803 0.98229 0.90483 0.77051 0.58779
70
71
Columns 12 through 22:
72
73
0.36812 0.12533 -0.12533 -0.36812 -0.58779 -0.77051 -0.90483 -0.98229 -0.99803 -0.95106 -0.84433
74
75
Columns 23 through 33:
76
77
-0.68455 -0.48175 -0.24869 -0.00000 0.24869 0.48175 0.68455 0.84433 0.95106 0.99803 0.98229
78
79
Columns 34 through 44:
80
81
0.90483 0.77051 0.58779 0.36812 0.12533 -0.12533 -0.36812 -0.58779 -0.77051 -0.90483 -0.98229
82
83
Columns 45 through 55:
84
85
-0.99803 -0.95106 -0.84433 -0.68455 -0.48175 -0.24869 -0.00000 0.24869 0.48175 0.68455 0.84433
86
87
Columns 56 through 66:
88
89
0.95106 0.99803 0.98229 0.90483 0.77051 0.58779 0.36812 0.12533 -0.12533 -0.36812 -0.58779
90
91
Columns 67 through 77:
92
93
-0.77051 -0.90483 -0.98229 -0.99803 -0.95106 -0.84433 -0.68455 -0.48175 -0.24869 -0.00000 0.24869
94
95
Columns 78 through 88:
96
97
0.48175 0.68455 0.84433 0.95106 0.99803 0.98229 0.90483 0.77051 0.58779 0.36812 0.12533
98
99
Columns 89 through 99:
100
101
-0.12533 -0.36812 -0.58779 -0.77051 -0.90483 -0.98229 -0.99803 -0.95106 -0.84433 -0.68455 -0.48175
102
103
octave:3> y2 = cos(2*pi*4*t)
104
y2 =
105
106
Columns 1 through 10:
107
108
1.000000 0.968583 0.876307 0.728969 0.535827 0.309017 0.062791 -0.187381 -0.425779 -0.637424
109
110
Columns 11 through 20:
111
112
-0.809017 -0.929776 -0.992115 -0.992115 -0.929776 -0.809017 -0.637424 -0.425779 -0.187381 0.062791
113
114
Columns 21 through 30:
115
116
0.309017 0.535827 0.728969 0.876307 0.968583 1.000000 0.968583 0.876307 0.728969 0.535827
117
118
Columns 31 through 40:
119
120
0.309017 0.062791 -0.187381 -0.425779 -0.637424 -0.809017 -0.929776 -0.992115 -0.992115 -0.929776
121
122
Columns 41 through 50:
123
124
-0.809017 -0.637424 -0.425779 -0.187381 0.062791 0.309017 0.535827 0.728969 0.876307 0.968583
125
126
Columns 51 through 60:
127
128
1.000000 0.968583 0.876307 0.728969 0.535827 0.309017 0.062791 -0.187381 -0.425779 -0.637424
129
130
Columns 61 through 70:
131
132
-0.809017 -0.929776 -0.992115 -0.992115 -0.929776 -0.809017 -0.637424 -0.425779 -0.187381 0.062791
133
134
Columns 71 through 80:
135
136
0.309017 0.535827 0.728969 0.876307 0.968583 1.000000 0.968583 0.876307 0.728969 0.535827
137
138
Columns 81 through 90:
139
140
0.309017 0.062791 -0.187381 -0.425779 -0.637424 -0.809017 -0.929776 -0.992115 -0.992115 -0.929776
141
142
Columns 91 through 99:
143
144
-0.809017 -0.637424 -0.425779 -0.187381 0.062791 0.309017 0.535827 0.728969 0.876307
145
146
octave:4> plot(t,y2);
147
octave:5> plot(t,y1);
148
octave:6> plot(t,y2);
149
octave:7> plot(t,y1);
150
octave:8> plot(t,y2);
151
octave:9> plot(t,y1);
152
octave:10> hold on;
153
octave:11> plot(t,y2,'r');
154
octave:12> xlabel('time');
155
octave:13> ylabel('value');
156
octave:14> legend('sin','cos');
157
octave:15> title('Merged Plot');
158
octave:16> figure(1);
159
octave:17> plot(t,y1);
160
octave:18> figure(2);
161
octave:19> plot(t,y2);
162
octave:20> subplot(1,2,1); #Divides plot 1x2 grid (1st two args, last arg: 1st element)
163
octave:21> plot(t,y1);#plot the sine graph in the 1sy grid
164
octave:22> plot(t,y2);#plot the cosine graph in the 1st grid
165
octave:23> subplot(1,2,2);
166
octave:24> plot(t,y2);#plot the cosine graph in the 2nd grid
167
octave:25> plot(t,y2);#plot the cosine graph in the 2nd grid
168
#line 21-25 gave me wrong output because I plotted the 2nd one in 1st grid
169
octave:26> subplot(1,2,1);
170
octave:27> plot(t,y1);
171
octave:28> subplot(1,2,2);
172
octave:29> plot(t,y2);
173
octave:30> axis([0.5 1 -1 1])
174
octave:31> #Range - vertical: 0.5 -1, horizontal: -1 1
175
octave:31> clf; #clear figure
176
octave:32> subplot(1,2,1);
177
octave:33> plot(t,y1);
178
octave:34> subplot(1,2,2);
179
octave:35> plot(t,y2);
180
octave:36> clf;
181
octave:37> A = magic(5)
182
A =
183
184
17 24 1 8 15
185
23 5 7 14 16
186
4 6 13 20 22
187
10 12 19 21 3
188
11 18 25 2 9
189
190
octave:38> imagesc(A); #Plots a 5x5 grid with diff colors
191
octave:39> color bar
192
warning: the 'color' function belongs to the optim package from Octave Forge
193
which you have installed but not loaded. To load the package, run 'pkg
194
load optim' from the Octave prompt.
195
196
Please read <https://www.octave.org/missing.html> to learn how you can
197
contribute missing functionality.
198
error: 'color' undefined near line 1 column 1
199
octave:39> pkg load optim
200
octave:40> color bar
201
warning: the 'color' function belongs to the optim package from Octave Forge but
202
has not yet been implemented.
203
204
Please read <https://www.octave.org/missing.html> to learn how you can
205
contribute missing functionality.
206
error: 'color' undefined near line 1 column 1
207
octave:40> colorbar
208
octave:41> imagesc(A), colorbar, colormap(green);
209
error: 'green' undefined near line 1 column 32
210
octave:41> imagesc(A), colorbar, colormap green;
211
error: colormap: failed to set MAP <green>
212
error: called from
213
colormap at line 111 column 11
214
octave:41> imagesc(A), colorbar, colormap gray;
215
octave:42> imagesc(A), colorbar, colormap blue;
216
error: colormap: failed to set MAP <blue>
217
error: called from
218
colormap at line 111 column 11
219
octave:42> help colormap;
220
'colormap' is a function from the file C:\Octave\OCTAVE~1.1\share\octave\4.4.1\m\image\colormap.m
221
222
-- CMAP = colormap ()
223
-- CMAP = colormap (MAP)
224
-- CMAP = colormap ("default")
225
-- CMAP = colormap (MAP_NAME)
226
-- CMAP = colormap (HAX, ...)
227
-- colormap MAP_NAME
228
Query or set the current colormap.
229
230
With no input arguments, 'colormap' returns the current color map.
231
232
'colormap (MAP)' sets the current colormap to MAP. The colormap
233
should be an N row by 3 column matrix. The columns contain red,
234
green, and blue intensities respectively. All entries must be
235
between 0 and 1 inclusive. The new colormap is returned.
236
237
'colormap ("default")' restores the default colormap (the 'viridis'
238
map with 64 entries). The default colormap is returned.
239
240
The map may also be specified by a string, MAP_NAME, which is the
241
name of a function that returns a colormap.
242
243
If the first argument HAX is an axes handle, then the colormap for
244
those axes is queried or set.
245
246
For convenience, it is also possible to use this function with the
247
command form, 'colormap MAP_NAME'.
248
249
The list of built-in colormaps is:
250
251
Map Description
252
--------------------------------------------------------------------------
253
viridis default
254
jet colormap traversing blue, cyan, green, yellow, red.
255
cubehelix colormap traversing black, blue, green, red, white with
256
increasing intensity.
257
hsv cyclic colormap traversing Hue, Saturation, Value space.
258
rainbow colormap traversing red, yellow, blue, green, violet.
259
--------- --------------------------------------------------------------
260
hot colormap traversing black, red, orange, yellow, white.
261
cool colormap traversing cyan, purple, magenta.
262
spring colormap traversing magenta to yellow.
263
summer colormap traversing green to yellow.
264
autumn colormap traversing red, orange, yellow.
265
winter colormap traversing blue to green.
266
--------- --------------------------------------------------------------
267
gray colormap traversing black to white in shades of gray.
268
bone colormap traversing black, gray-blue, white.
269
copper colormap traversing black to light copper.
270
pink colormap traversing black, gray-pink, white.
271
ocean colormap traversing black, dark-blue, white.
272
--------- --------------------------------------------------------------
273
colorcube equally spaced colors in RGB color space.
274
flag cyclic 4-color map of red, white, blue, black.
275
lines cyclic colormap with colors from axes "ColorOrder"
276
property.
277
prism cyclic 6-color map of red, orange, yellow, green, blue,
278
violet.
279
--------- --------------------------------------------------------------
280
white all white colormap (no colors).
281
282
See also: viridis, jet, cubehelix, hsv, rainbow, hot, cool, spring,
283
summer, autumn, winter, gray, bone, copper, pink, ocean, colorcube,
284
flag, lines, prism, white.
285
286
Additional help for built-in functions and operators is
287
available in the online version of the manual. Use the command
288
'doc <topic>' to search the manual index.
289
290
Help and information about Octave is also available on the WWW
291
at https://www.octave.org and via the [email protected]
292
mailing list.
293
octave:43> imagesc(A), colorbar, colormap ocean;
294
octave:44> imagesc(A), colorbar, colormap copper;
295
octave:45> imagesc(A), colorbar, colormap prism;
296
octave:46> imagesc(A), colorbar, colormap flag;
297
octave:47> imagesc(A), colorbar, colormap lines;
298
octave:48> imagesc(A), colorbar, colormap colorcube;
299
octave:49> imagesc(A), colorbar, colormap cubehelix;
300
octave:50> imagesc(A), colorbar, colormap hsv;
301