1 00:00:00,111 --> 00:00:02,628 In this second tutorial video on 2 00:00:02,630 --> 00:00:03,904 Octave, I'd like to start 3 00:00:03,930 --> 00:00:07,322 to tell you how to move data around in Octave. 4 00:00:07,340 --> 00:00:08,783 So, if you have data for 5 00:00:08,783 --> 00:00:12,125 a machine learning problem, how do you load that data in Octave? 6 00:00:12,125 --> 00:00:13,693 How do you put it into matrix? 7 00:00:13,693 --> 00:00:15,284 How do you manipulate these matrices? 8 00:00:15,290 --> 00:00:16,982 How do you save the results? 9 00:00:17,000 --> 00:00:22,185 How do you move data around and operate with data? 10 00:00:22,900 --> 00:00:25,044 Here's my Octave window as 11 00:00:25,044 --> 00:00:29,256 before, picking up from where we left off in the last video. 12 00:00:29,290 --> 00:00:31,132 If I type A, that's 13 00:00:31,140 --> 00:00:32,258 the matrix so we generate it, right, 14 00:00:32,258 --> 00:00:35,197 with this command equals one, two, 15 00:00:35,197 --> 00:00:38,152 three, four, five, six, and 16 00:00:38,190 --> 00:00:40,696 this is a three by two matrix. 17 00:00:40,710 --> 00:00:42,415 The size command in Octave 18 00:00:42,430 --> 00:00:46,361 lets you, tells you what is the size of a matrix. 19 00:00:46,361 --> 00:00:48,207 So size A returns three, two. 20 00:00:48,207 --> 00:00:50,160 It turns out that 21 00:00:50,180 --> 00:00:52,155 this size command itself is actually 22 00:00:52,155 --> 00:00:54,591 returning a one by two matrix. 23 00:00:54,591 --> 00:00:56,598 So you can actually set SZ equals 24 00:00:56,598 --> 00:00:58,370 size of A and SZ 25 00:00:58,380 --> 00:00:59,597 is now a one by two 26 00:00:59,597 --> 00:01:01,627 matrix where the first element 27 00:01:01,640 --> 00:01:04,689 of this is three, and the second element of this is two. 28 00:01:04,700 --> 00:01:07,494 So, if you just type size of SZ. Does SZ 29 00:01:07,494 --> 00:01:08,898 is a one by 30 00:01:08,898 --> 00:01:10,862 two matrix whose two elements 31 00:01:10,862 --> 00:01:13,721 contain the dimensions of the 32 00:01:13,721 --> 00:01:15,279 matrix A. You can 33 00:01:15,279 --> 00:01:17,787 also type size A one 34 00:01:17,787 --> 00:01:19,505 to give you back the first 35 00:01:19,510 --> 00:01:21,542 dimension of A, size 36 00:01:21,542 --> 00:01:22,662 of the first dimension of A. 37 00:01:22,680 --> 00:01:24,108 So that's the number 38 00:01:24,110 --> 00:01:26,307 of rows and size A two 39 00:01:26,320 --> 00:01:28,361 to give you back two, which 40 00:01:28,361 --> 00:01:29,598 is the number of columns in 41 00:01:29,598 --> 00:01:31,942 the matrix A. If you 42 00:01:31,950 --> 00:01:34,034 have a vector V, so 43 00:01:34,034 --> 00:01:36,016 let's say V equals one, two, 44 00:01:36,030 --> 00:01:38,089 three, four, and you 45 00:01:38,089 --> 00:01:40,830 type length V. What 46 00:01:40,830 --> 00:01:42,097 this does is it gives you 47 00:01:42,097 --> 00:01:44,123 the size of the longest dimension. 48 00:01:44,170 --> 00:01:45,609 So you can also type 49 00:01:45,609 --> 00:01:48,487 length A and because 50 00:01:48,500 --> 00:01:49,856 A is a three by 51 00:01:49,860 --> 00:01:52,305 two matrix, the longer 52 00:01:52,330 --> 00:01:53,825 dimension is of size 53 00:01:53,825 --> 00:01:56,145 three, so this should print out three. 54 00:01:56,145 --> 00:01:58,805 But usually we apply length only to vectors. 55 00:01:58,810 --> 00:02:00,194 So you know, length one, two, 56 00:02:00,200 --> 00:02:02,222 three, four, five, rather 57 00:02:02,230 --> 00:02:04,010 than apply length to matrices 58 00:02:04,010 --> 00:02:07,205 because that's a little more confusing. 59 00:02:07,620 --> 00:02:10,122 Now, let's look 60 00:02:10,122 --> 00:02:11,843 at how the load data and 61 00:02:11,860 --> 00:02:13,732 find data on the file system. 62 00:02:13,732 --> 00:02:15,254 When we start an Octave 63 00:02:15,254 --> 00:02:16,882 we're usually, we're often in 64 00:02:16,920 --> 00:02:19,098 a path that 65 00:02:19,098 --> 00:02:21,738 is, you know, the location of where the Octave location is. 66 00:02:21,750 --> 00:02:24,042 So the PWD command shows 67 00:02:24,060 --> 00:02:25,619 the current directory, or the 68 00:02:25,640 --> 00:02:28,738 current path that Octave is in. 69 00:02:28,738 --> 00:02:31,932 So right now we're in this maybe somewhat off scale directory. 70 00:02:31,932 --> 00:02:33,999 The CD command stands 71 00:02:34,000 --> 00:02:35,322 for change directory, so I 72 00:02:35,330 --> 00:02:40,681 can go to C:/Users/Ang/Desktop, and 73 00:02:40,681 --> 00:02:43,657 now I'm in, you know, in my Desktop 74 00:02:43,657 --> 00:02:45,925 and if I type ls, 75 00:02:45,925 --> 00:02:49,447 ls is, it comes from a Unix or a Linux command. 76 00:02:49,447 --> 00:02:50,648 But, ls will list the 77 00:02:50,648 --> 00:02:52,435 directories on my desktop and 78 00:02:52,435 --> 00:02:54,137 so these are the files 79 00:02:54,140 --> 00:02:58,184 that are on my Desktop right now. 80 00:03:15,850 --> 00:03:17,838 In fact, on my desktop are 81 00:03:17,838 --> 00:03:19,920 two files: Features X and 82 00:03:19,920 --> 00:03:21,689 Price Y that's maybe come 83 00:03:21,689 --> 00:03:23,596 from a machine learning problem I want to solve. 84 00:03:23,620 --> 00:03:25,830 So, here's my desktop. 85 00:03:25,830 --> 00:03:29,144 Here's Features X, and 86 00:03:29,144 --> 00:03:31,598 Features X is this window, 87 00:03:31,630 --> 00:03:34,492 excuse me, is this file with two columns of data. 88 00:03:34,492 --> 00:03:36,702 This is actually my housing prices data. 89 00:03:36,750 --> 00:03:38,374 So I think, you know, I 90 00:03:38,374 --> 00:03:40,652 think I have forty-seven rows in this data set. 91 00:03:40,652 --> 00:03:42,344 And so the first house 92 00:03:42,350 --> 00:03:43,966 has size two hundred four 93 00:03:43,970 --> 00:03:46,172 square feet, has three bedrooms; second 94 00:03:46,190 --> 00:03:47,367 house has sixteen hundred square 95 00:03:47,367 --> 00:03:49,862 feet, has three bedrooms; and so on. 96 00:03:49,880 --> 00:03:52,302 And Price Y is this 97 00:03:52,302 --> 00:03:55,020 file that has 98 00:03:55,040 --> 00:03:57,575 the prices of the data in my training set. 99 00:03:57,575 --> 00:03:59,735 So, Features X and 100 00:03:59,735 --> 00:04:03,061 Price Y are just text files with my data. 101 00:04:03,061 --> 00:04:04,770 How do I load this data into Octave? 102 00:04:04,770 --> 00:04:06,050 Well, I just type 103 00:04:06,090 --> 00:04:08,163 the command load Features X dot 104 00:04:08,163 --> 00:04:10,069 dat and if I 105 00:04:10,069 --> 00:04:11,991 do that, I load the Features X 106 00:04:11,991 --> 00:04:15,772 and can load Price Y dot dat. And 107 00:04:15,772 --> 00:04:17,323 by the way, there are multiple ways to do this. 108 00:04:17,323 --> 00:04:19,245 This command if you put 109 00:04:19,245 --> 00:04:20,916 Features X dot dat on that 110 00:04:20,916 --> 00:04:22,533 in strings and load it like so. 111 00:04:22,550 --> 00:04:25,477 This is a typo there. 112 00:04:25,490 --> 00:04:27,317 This is an equivalent command. 113 00:04:27,317 --> 00:04:29,334 So you can, this 114 00:04:29,360 --> 00:04:31,985 way I'm just putting the file name of the string 115 00:04:32,000 --> 00:04:34,148 in the founding in a 116 00:04:34,148 --> 00:04:35,716 string and in an 117 00:04:35,716 --> 00:04:38,902 Octave use single quotes to 118 00:04:38,930 --> 00:04:41,876 represent strings, like so. 119 00:04:41,910 --> 00:04:42,837 So that's a string, and we 120 00:04:42,860 --> 00:04:45,517 can load the file 121 00:04:45,517 --> 00:04:48,324 whose name is given by that string. 122 00:04:48,324 --> 00:04:50,919 Now the WHO command now 123 00:04:50,960 --> 00:04:52,538 shows me what variables I 124 00:04:52,538 --> 00:04:54,605 have in my Octave workspace. 125 00:04:54,605 --> 00:04:56,310 So Who shows me whether 126 00:04:56,330 --> 00:04:59,952 the variables that Octave has in memory currently. 127 00:04:59,952 --> 00:05:01,367 Features X and Price Y 128 00:05:01,370 --> 00:05:02,991 are among them, as well as 129 00:05:02,991 --> 00:05:04,120 the variables that, you know, 130 00:05:04,170 --> 00:05:06,311 we created earlier in this session. 131 00:05:06,311 --> 00:05:09,198 So I can type Features X 132 00:05:09,198 --> 00:05:11,062 to display features X. And 133 00:05:11,062 --> 00:05:14,164 there's my data. 134 00:05:14,200 --> 00:05:16,419 And I can type size features 135 00:05:16,419 --> 00:05:18,022 X and that's my 136 00:05:18,022 --> 00:05:20,519 47 by two matrix. 137 00:05:20,519 --> 00:05:22,307 And some of these size, press 138 00:05:22,320 --> 00:05:23,729 Y, that gives me 139 00:05:23,729 --> 00:05:26,753 my 47 by one vector. 140 00:05:26,753 --> 00:05:30,125 This is a 47 dimensional vector. 141 00:05:30,125 --> 00:05:32,080 This is all common vector that 142 00:05:32,080 --> 00:05:35,231 has all the prices Y in my training set. 143 00:05:35,240 --> 00:05:37,584 Now the who function shows 144 00:05:37,600 --> 00:05:40,086 you one of the variables that, in the current workspace. 145 00:05:40,086 --> 00:05:42,195 There's also the who S 146 00:05:42,195 --> 00:05:45,369 variable that gives you the detailed view. 147 00:05:45,369 --> 00:05:47,252 And so this also, with 148 00:05:47,270 --> 00:05:48,574 an S at the end this also 149 00:05:48,574 --> 00:05:49,979 lists my variables except that it 150 00:05:49,979 --> 00:05:51,782 now lists the sizes as well. 151 00:05:51,790 --> 00:05:52,759 So A is a three by 152 00:05:52,759 --> 00:05:54,764 two matrix and features 153 00:05:54,764 --> 00:05:56,545 X as a 47 by 2 matrix. 154 00:05:56,545 --> 00:05:59,327 Price Y is a 47 by one matrix. 155 00:05:59,327 --> 00:06:01,098 Meaning this is just a vector. 156 00:06:01,130 --> 00:06:03,438 And it shows, you know, how many bytes of memory it's taking up. 157 00:06:03,438 --> 00:06:06,020 As well as what type of data this is. 158 00:06:06,020 --> 00:06:07,765 Double means double position floating 159 00:06:07,765 --> 00:06:08,915 point so that just means that 160 00:06:08,915 --> 00:06:13,148 these are real values, the floating point numbers. 161 00:06:13,148 --> 00:06:14,190 Now if you want to get 162 00:06:14,190 --> 00:06:17,316 rid of a variable you can use the clear command. 163 00:06:17,340 --> 00:06:21,124 So clear features X and type whose again. 164 00:06:21,130 --> 00:06:23,448 You notice that the features X 165 00:06:23,448 --> 00:06:26,465 variable has now disappeared. 166 00:06:27,270 --> 00:06:28,567 And how do we save data? 167 00:06:28,567 --> 00:06:29,221 Let's see. 168 00:06:29,221 --> 00:06:30,411 Let's take the variable V and 169 00:06:30,411 --> 00:06:33,075 say that it's a price Y 1 colon 10. 170 00:06:33,075 --> 00:06:34,826 This sets V to be 171 00:06:34,826 --> 00:06:38,574 the first 10 elements of 172 00:06:38,860 --> 00:06:43,215 vector Y. So let's type who or whose. 173 00:06:43,220 --> 00:06:46,612 Whereas Y was a 47 by 1 vector. 174 00:06:46,612 --> 00:06:48,474 V is now 10 by 1. 175 00:06:48,474 --> 00:06:50,809 B equals price Y, one 176 00:06:50,809 --> 00:06:52,451 column ten that sets it 177 00:06:52,451 --> 00:06:53,520 to the just the first ten 178 00:06:53,520 --> 00:06:55,705 elements of Y. Let's say 179 00:06:55,705 --> 00:06:57,398 I wanna save this to date to disc 180 00:06:57,398 --> 00:07:00,129 the command save, hello.mat 181 00:07:00,129 --> 00:07:02,302 V. This will 182 00:07:02,310 --> 00:07:04,357 save the variable V into 183 00:07:04,370 --> 00:07:05,690 a file called hello.mat. 184 00:07:05,720 --> 00:07:08,490 So let's do that. 185 00:07:08,640 --> 00:07:10,965 And now a file 186 00:07:11,030 --> 00:07:13,181 has appeared on my Desktop, you 187 00:07:13,181 --> 00:07:15,066 know, called Hello.mat. 188 00:07:15,066 --> 00:07:16,509 I happen to have MATLAB installed 189 00:07:16,530 --> 00:07:17,962 in this window, which is why, 190 00:07:17,962 --> 00:07:19,711 you know, this icon looks 191 00:07:19,711 --> 00:07:21,621 like this because Windows is recognized 192 00:07:21,621 --> 00:07:23,559 as it's a MATLAB file,but don't 193 00:07:23,559 --> 00:07:24,882 worry about it if this file 194 00:07:24,890 --> 00:07:26,051 looks like it has a different 195 00:07:26,051 --> 00:07:28,778 icon on your machine and 196 00:07:28,778 --> 00:07:31,017 let's say I clear all my variables. 197 00:07:31,020 --> 00:07:32,602 So, if you type clear without 198 00:07:32,602 --> 00:07:36,061 anything then this actually deletes all of the variables in your workspace. 199 00:07:36,080 --> 00:07:39,078 So there's now nothing left in the workspace. 200 00:07:39,078 --> 00:07:41,856 And if I load hello.mat, 201 00:07:41,856 --> 00:07:44,388 I can now load back my 202 00:07:44,388 --> 00:07:46,054 variable v, which is 203 00:07:46,054 --> 00:07:47,830 the data that I 204 00:07:47,830 --> 00:07:51,035 previously saved into the hello.mat file. 205 00:07:51,035 --> 00:07:54,636 So, hello.mat, what we did just now to save hello.mat 206 00:07:54,636 --> 00:07:55,877 to view, this save the 207 00:07:55,877 --> 00:07:57,811 data in a binary format, 208 00:07:57,850 --> 00:07:59,702 a somewhat more compressed binary format. 209 00:07:59,702 --> 00:08:01,077 So if v is a lot 210 00:08:01,077 --> 00:08:03,899 of data, this, you know, will be somewhat more compressing. 211 00:08:03,899 --> 00:08:05,645 Will take off less the space. 212 00:08:05,650 --> 00:08:06,784 If you want to save your 213 00:08:06,784 --> 00:08:08,959 data in a human readable 214 00:08:08,959 --> 00:08:11,870 format then you type save hello.text 215 00:08:11,870 --> 00:08:14,055 the variable v and then -ascii. 216 00:08:14,110 --> 00:08:16,083 So, this will save 217 00:08:16,083 --> 00:08:18,787 it as a text 218 00:08:18,840 --> 00:08:21,352 or as ascii format of text. 219 00:08:21,352 --> 00:08:22,802 And now, once I've done 220 00:08:22,802 --> 00:08:24,973 that, I have this file. 221 00:08:24,973 --> 00:08:26,115 Hello.text has just 222 00:08:26,130 --> 00:08:28,463 appeared on my desktop, and 223 00:08:28,463 --> 00:08:29,951 if I open this up, we 224 00:08:29,951 --> 00:08:31,016 see that this is a text 225 00:08:31,016 --> 00:08:33,958 file with my data saved away. 226 00:08:33,958 --> 00:08:36,698 So that's how you load and save data. 227 00:08:36,698 --> 00:08:38,832 Now let's talk a bit about how to manipulate data. 228 00:08:38,832 --> 00:08:40,526 Let's set a equals to that 229 00:08:40,526 --> 00:08:44,910 matrix again so is my three by two matrix. 230 00:08:45,710 --> 00:08:46,778 So as indexing. 231 00:08:46,778 --> 00:08:48,493 So type A 3, 2. 232 00:08:48,493 --> 00:08:51,219 This indexes into 233 00:08:51,219 --> 00:08:52,917 the 3, 2 elements of 234 00:08:52,917 --> 00:08:54,308 the matrix A. So, this 235 00:08:54,370 --> 00:08:56,320 is what, you know, 236 00:08:56,400 --> 00:08:57,488 in normally, we will write this 237 00:08:57,510 --> 00:09:00,421 as a subscript 3, 2 238 00:09:00,430 --> 00:09:02,280 or A subscript, 239 00:09:03,570 --> 00:09:05,320 you know, 3, 2 240 00:09:05,380 --> 00:09:07,028 and so that's the element and 241 00:09:07,028 --> 00:09:08,664 third row and second column 242 00:09:08,664 --> 00:09:11,539 of A which is the element of six. 243 00:09:11,590 --> 00:09:13,820 I can also type A to 244 00:09:14,550 --> 00:09:16,770 comma colon to fetch 245 00:09:16,770 --> 00:09:18,851 everything in the second row. 246 00:09:18,851 --> 00:09:22,806 So, the colon means every 247 00:09:22,810 --> 00:09:27,381 element along that row or column. 248 00:09:27,420 --> 00:09:29,274 So, a of 2 comma 249 00:09:29,274 --> 00:09:32,425 colon is this second row of a. Right. 250 00:09:32,470 --> 00:09:35,662 And similarly, if I do a colon comma 2 251 00:09:35,680 --> 00:09:38,262 then this means get everything in 252 00:09:38,262 --> 00:09:41,328 the second column of A. So, this gives me 2 4 6. 253 00:09:41,328 --> 00:09:42,921 Right this means of 254 00:09:42,930 --> 00:09:45,467 A. everything, second column. 255 00:09:45,500 --> 00:09:46,967 So, this is my second 256 00:09:46,970 --> 00:09:49,636 column A, which is 2 4 6. 257 00:09:49,650 --> 00:09:51,267 Now, you can also 258 00:09:51,280 --> 00:09:54,148 use somewhat most of the sophisticated index in the operations. 259 00:09:54,148 --> 00:09:56,575 So So, we just click each of an example. 260 00:09:56,575 --> 00:09:58,537 You do this maybe less often, 261 00:09:58,550 --> 00:10:02,231 but let me do this A 1 3 comma colon. 262 00:10:02,231 --> 00:10:03,471 This means get all of 263 00:10:03,500 --> 00:10:07,444 the elements of A who's first indexes one or three. 264 00:10:07,450 --> 00:10:08,765 This means I get everything from 265 00:10:08,765 --> 00:10:10,588 the first and third rows of 266 00:10:10,603 --> 00:10:12,780 A and from all 267 00:10:13,240 --> 00:10:13,240 columns. 268 00:10:14,163 --> 00:10:16,430 So, this was the 269 00:10:16,800 --> 00:10:18,260 matrix A and so A 270 00:10:18,440 --> 00:10:21,872 1 3 comma colon means get 271 00:10:21,900 --> 00:10:23,222 everything from the first row 272 00:10:23,250 --> 00:10:25,023 and from the second row and 273 00:10:25,023 --> 00:10:27,172 from the third row and the 274 00:10:27,172 --> 00:10:28,313 colon means, you know, one both 275 00:10:28,313 --> 00:10:29,585 of first and the second 276 00:10:29,585 --> 00:10:31,045 columns and so this 277 00:10:31,045 --> 00:10:32,842 gives me this 1 2 5 6. 278 00:10:32,842 --> 00:10:34,353 Although, you use the source 279 00:10:34,353 --> 00:10:37,182 of more subscript index 280 00:10:37,182 --> 00:10:39,819 operations maybe somewhat less often. 281 00:10:40,210 --> 00:10:41,453 To show you what else we can do. 282 00:10:41,453 --> 00:10:43,617 Here's the A matrix and this 283 00:10:43,617 --> 00:10:47,276 source A colon, to give me the second column. 284 00:10:47,276 --> 00:10:49,773 You can also use this to do assignments. 285 00:10:49,773 --> 00:10:51,178 So I can take the second column of 286 00:10:51,190 --> 00:10:52,949 A and assign that to 287 00:10:52,950 --> 00:10:55,605 10, 11, 12, and 288 00:10:55,670 --> 00:10:58,084 if I do that I'm now, you 289 00:10:58,120 --> 00:10:59,220 know, taking the second column of 290 00:10:59,290 --> 00:11:02,768 a and I'm assigning this column vector 10, 11, 12 to it. 291 00:11:02,768 --> 00:11:05,440 So, now a is this matrix that's 1, 3, 5. 292 00:11:05,480 --> 00:11:08,760 And the second column has been replaced by 10, 11, 12. 293 00:11:08,760 --> 00:11:14,513 And here's another operation. 294 00:11:14,680 --> 00:11:15,917 Let's set A to be equal 295 00:11:15,917 --> 00:11:17,738 to A comma 100, 101, 296 00:11:17,750 --> 00:11:21,605 102 like so and what 297 00:11:21,605 --> 00:11:24,109 this will do is 298 00:11:24,120 --> 00:11:28,025 depend another column vector 299 00:11:28,047 --> 00:11:29,855 to the right. 300 00:11:29,890 --> 00:11:33,230 So, now, oops. 301 00:11:33,260 --> 00:11:36,798 I think I made a little mistake. 302 00:11:36,800 --> 00:11:41,065 Should have put semicolons there 303 00:11:41,700 --> 00:11:43,910 and now A is equals to this. 304 00:11:43,910 --> 00:11:44,564 Okay? 305 00:11:44,564 --> 00:11:45,479 I hope that makes sense. 306 00:11:45,479 --> 00:11:46,480 So this 100, 101, 102. 307 00:11:46,480 --> 00:11:48,804 This is a column vector 308 00:11:48,820 --> 00:11:51,668 and what we did 309 00:11:51,668 --> 00:11:53,386 was we set A, take 310 00:11:53,386 --> 00:11:56,156 A and set it to the original definition. 311 00:11:56,156 --> 00:11:57,368 And then we put that column 312 00:11:57,380 --> 00:11:59,192 vector to the right 313 00:11:59,192 --> 00:12:00,217 and so, we ended up taking 314 00:12:00,217 --> 00:12:04,288 the matrix A and--which was 315 00:12:04,288 --> 00:12:05,405 these six elements on the left. 316 00:12:05,405 --> 00:12:06,785 So we took matrix 317 00:12:06,810 --> 00:12:08,564 A and we appended another 318 00:12:08,564 --> 00:12:09,793 column vector to the right; 319 00:12:09,793 --> 00:12:11,814 which is now why A is 320 00:12:11,814 --> 00:12:16,083 a three by three matrix that looks like that. 321 00:12:16,200 --> 00:12:18,005 And finally, one neat 322 00:12:18,010 --> 00:12:19,802 trick that I sometimes use 323 00:12:19,810 --> 00:12:22,022 if you do just a and just a colon like so. 324 00:12:22,022 --> 00:12:25,585 This is a somewhat special case syntax. 325 00:12:25,590 --> 00:12:28,695 What this means is that put all elements with A into 326 00:12:28,695 --> 00:12:30,751 a single column vector 327 00:12:30,850 --> 00:12:34,513 and this gives me a 9 by 1 vector. 328 00:12:34,513 --> 00:12:38,584 They adjust the other ones are combined together. 329 00:12:39,700 --> 00:12:45,258 Just a couple more examples. Let's see. Let's 330 00:12:45,300 --> 00:12:52,073 say I set A to be equal to 123456, okay? 331 00:12:52,181 --> 00:12:54,035 And let's say 332 00:12:54,060 --> 00:12:55,674 I set a B to B 333 00:12:55,680 --> 00:12:58,984 equal to 11, 12, 13, 14, 15, 16. 334 00:12:58,984 --> 00:13:00,346 I can create a new 335 00:13:00,346 --> 00:13:03,161 matrix C as A B. 336 00:13:03,200 --> 00:13:05,010 This just means my 337 00:13:05,080 --> 00:13:06,666 Matrix A. Here's my Matrix 338 00:13:06,666 --> 00:13:08,426 B and I've set C 339 00:13:08,426 --> 00:13:11,053 to be equal to AB. 340 00:13:11,070 --> 00:13:12,225 What I'm doing is I'm taking 341 00:13:12,225 --> 00:13:15,438 these two matrices and just concatenating onto each other. 342 00:13:15,438 --> 00:13:18,408 So the left, matrix A on the left. 343 00:13:18,420 --> 00:13:20,786 And I have the matrix B on the right. 344 00:13:20,800 --> 00:13:23,738 And that's how I formed 345 00:13:23,830 --> 00:13:27,145 this matrix C by putting them together. 346 00:13:27,145 --> 00:13:28,927 I can also do C equals 347 00:13:28,927 --> 00:13:31,975 A semicolon B. The semi 348 00:13:32,000 --> 00:13:35,552 colon notation means that 349 00:13:35,552 --> 00:13:38,881 I go put the next thing at the bottom. 350 00:13:38,881 --> 00:13:39,880 So, I'll do is a 351 00:13:39,910 --> 00:13:41,169 equals semicolon B. It also 352 00:13:41,170 --> 00:13:42,408 puts the matrices A 353 00:13:42,460 --> 00:13:44,048 and B together except that it 354 00:13:44,048 --> 00:13:46,408 now puts them on top of each other. 355 00:13:46,408 --> 00:13:49,675 so now I have A on top and B at the bottom and C here 356 00:13:49,675 --> 00:13:52,038 is now in 6 by 2 matrix. 357 00:13:52,038 --> 00:13:54,263 So, just say the semicolon 358 00:13:54,270 --> 00:13:56,705 thing usually means, you know, go to the next line. 359 00:13:56,705 --> 00:13:58,463 So, C is comprised by a 360 00:13:58,463 --> 00:13:59,598 and then go to the bottom 361 00:13:59,598 --> 00:14:00,610 of that and then put b 362 00:14:00,690 --> 00:14:02,320 in the bottom and by the 363 00:14:02,390 --> 00:14:04,225 way, this A B is 364 00:14:04,225 --> 00:14:05,734 the same as A, B and 365 00:14:05,750 --> 00:14:09,106 so you know, either of these gives you the same result. 366 00:14:10,310 --> 00:14:11,916 So, with that, hopefully you 367 00:14:11,916 --> 00:14:14,256 now know how to construct 368 00:14:14,260 --> 00:14:17,207 matrices and hopefully starts 369 00:14:17,207 --> 00:14:18,223 to show you some of the 370 00:14:18,223 --> 00:14:19,822 commands that you use 371 00:14:19,850 --> 00:14:21,913 to quickly put together matrices and 372 00:14:21,940 --> 00:14:23,390 take matrices and, you know, 373 00:14:23,390 --> 00:14:24,984 slam them together to form 374 00:14:25,000 --> 00:14:27,009 bigger matrices, and with 375 00:14:27,009 --> 00:14:28,962 just a few lines of code, Octave 376 00:14:28,962 --> 00:14:30,770 is very convenient in terms 377 00:14:30,770 --> 00:14:32,683 of how quickly we can assemble 378 00:14:32,683 --> 00:14:36,033 complex matrices and move data around. 379 00:14:36,050 --> 00:14:38,027 So that's it for moving data around. 380 00:14:38,027 --> 00:14:39,347 In the next video we'll start 381 00:14:39,347 --> 00:14:40,783 to talk about how to actually 382 00:14:40,860 --> 00:14:46,232 do complex computations on this, on our data. 383 00:14:46,830 --> 00:14:48,256 So, hopefully that gives you 384 00:14:48,256 --> 00:14:49,961 a sense of how, with 385 00:14:49,961 --> 00:14:51,049 just a few commands, you can 386 00:14:51,049 --> 00:14:54,573 very quickly move data around in Octave. 387 00:14:54,590 --> 00:14:56,164 You know, you load and save vectors and 388 00:14:56,180 --> 00:14:58,059 matrices, load and save data, 389 00:14:58,090 --> 00:15:00,201 put together matrices to create 390 00:15:00,201 --> 00:15:02,990 bigger matrices, index into or select 391 00:15:02,990 --> 00:15:05,021 specific elements on the matrices. 392 00:15:05,021 --> 00:15:06,015 I know I went through a lot 393 00:15:06,015 --> 00:15:06,944 of commands, so I think 394 00:15:06,980 --> 00:15:08,244 the best thing for you to do 395 00:15:08,244 --> 00:15:09,741 is afterward, to look 396 00:15:09,741 --> 00:15:12,248 at the transcript of the things I was typing. 397 00:15:12,248 --> 00:15:13,286 You know, look at it. 398 00:15:13,286 --> 00:15:14,661 Look at the coursework site and download 399 00:15:14,661 --> 00:15:15,927 the transcript of the session 400 00:15:15,950 --> 00:15:17,479 from there and look through 401 00:15:17,479 --> 00:15:18,820 the transcript and type some 402 00:15:18,820 --> 00:15:21,942 of those commands into Octave yourself 403 00:15:21,942 --> 00:15:24,752 and start to play with these commands and get it to work. 404 00:15:24,752 --> 00:15:28,113 And obviously, you know, there's no point at all to try to memorize all these commands. 405 00:15:28,113 --> 00:15:30,030 It's just, but what you 406 00:15:30,030 --> 00:15:31,852 should do is, hopefully from 407 00:15:31,852 --> 00:15:32,910 this video you have gotten a 408 00:15:32,910 --> 00:15:35,065 sense of the sorts of things you can do. 409 00:15:35,100 --> 00:15:36,519 So that when later on when 410 00:15:36,520 --> 00:15:37,902 you are trying to program a learning 411 00:15:37,902 --> 00:15:39,630 algorithms yourself, if you 412 00:15:39,630 --> 00:15:40,921 are trying to find a specific 413 00:15:40,930 --> 00:15:42,455 command that maybe you think 414 00:15:42,455 --> 00:15:43,878 Octave can do because you think 415 00:15:43,878 --> 00:15:45,325 you might have seen it here, you 416 00:15:45,325 --> 00:15:47,300 should refer to the transcript 417 00:15:47,300 --> 00:15:48,545 of the session and look through 418 00:15:48,560 --> 00:15:51,693 that in order to find the commands you wanna use. 419 00:15:51,693 --> 00:15:53,069 So, that's it for 420 00:15:53,069 --> 00:15:54,841 moving data around and in 421 00:15:54,841 --> 00:15:56,060 the next video what I'd like 422 00:15:56,120 --> 00:15:57,699 to do is start to tell 423 00:15:57,740 --> 00:15:59,257 you how to actually do 424 00:15:59,257 --> 00:16:01,404 complex computations on our 425 00:16:01,410 --> 00:16:03,548 data, and how to 426 00:16:03,550 --> 00:16:04,866 compute on the data, and 427 00:16:04,866 --> 00:16:06,560 actually start to implement learning algorithms.