All language subtitles for 5. Matrix Selection and Indexing

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian Download
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,660 --> 00:00:05,070 Hello everyone and welcome to the lecture on Matrix selection and indexing. 2 00:00:05,070 --> 00:00:09,840 So just like with doctors we're going to be able to use the square bracket notation to select elements 3 00:00:10,020 --> 00:00:11,250 from a matrix. 4 00:00:11,250 --> 00:00:14,180 Let's go ahead and jump to our studio to see how this works. 5 00:00:14,670 --> 00:00:15,000 OK. 6 00:00:15,000 --> 00:00:20,430 So here are studio and let's go ahead and get a quick reminder of how we can use indexing for a vector 7 00:00:20,680 --> 00:00:21,040 . 8 00:00:21,080 --> 00:00:30,420 Imagine had a vector V of the elements 1 2 3 4 5 index and number two I would simply use square brackets 9 00:00:30,480 --> 00:00:34,040 and then put the index position where the element I want back. 10 00:00:34,080 --> 00:00:37,770 Or it could also put in the name if the vector was named. 11 00:00:37,800 --> 00:00:43,020 Now for matrices since we're dealing of two them mentions we'll need to use a comma to separate or indexing 12 00:00:43,020 --> 00:00:44,460 for each dimension. 13 00:00:44,460 --> 00:00:47,390 So let's go ahead and show you what this looks like. 14 00:00:47,400 --> 00:00:53,100 First off we'll start by making a matrix called Matt. 15 00:00:53,190 --> 00:00:59,530 The matrix function as a numeric sequential vector 1 through 50. 16 00:00:59,930 --> 00:01:03,110 We'll say by RHO is equal to false. 17 00:01:03,210 --> 00:01:11,250 Actually true excuse me and I'll specify the number of rows to be equal to 5. 18 00:01:11,580 --> 00:01:16,010 So it's going to take a look at that matrix real quick. 19 00:01:16,140 --> 00:01:21,690 So because my font's a little larger here it's going to be split into two parts but it is all just one 20 00:01:21,690 --> 00:01:27,900 matrix that's a 5 by 10 matrix so there's five rows with 10 columns here. 21 00:01:28,010 --> 00:01:33,990 You'll notice here that there's a square bracket index notation for the columns and the rows and that's 22 00:01:33,990 --> 00:01:38,560 the same kind of rotation we're going to be using when we select from this matrix. 23 00:01:38,580 --> 00:01:40,450 So let's go ahead and get started. 24 00:01:40,520 --> 00:01:43,780 The men really wanted to grab the first row. 25 00:01:43,920 --> 00:01:50,070 So for Matrix indexing notation what you're going to do for the square brackets is your first going 26 00:01:50,070 --> 00:01:56,970 to pass in the rows you want to if I just want the first row I'll put in one then you put a comma and 27 00:01:56,970 --> 00:02:01,580 then you pass in the columns you want if you want everything you just leave it blank. 28 00:02:01,590 --> 00:02:06,960 So if I want the first row that's going to return that first row for me. 29 00:02:06,960 --> 00:02:10,160 Let's go ahead and see what that looks like one more time. 30 00:02:10,170 --> 00:02:15,760 So I notice the first row was the numbers 1 2 3 4 5 6 7 8 9 and 10. 31 00:02:16,110 --> 00:02:24,940 So if I say first one comma nothing then I'm going to return all the columns for the first row. 32 00:02:24,960 --> 00:02:25,580 Great. 33 00:02:25,830 --> 00:02:30,720 Let's go ahead and see how I can grab the first column. 34 00:02:30,720 --> 00:02:34,580 So the first column is going to be nothing. 35 00:02:34,630 --> 00:02:36,460 Comma 1. 36 00:02:36,540 --> 00:02:43,740 Now what this means is grab everything all the rows from the first column so that in return will bring 37 00:02:43,740 --> 00:02:45,460 back the first column. 38 00:02:45,810 --> 00:02:47,850 So in general we can think of this. 39 00:02:47,910 --> 00:02:54,030 If I just go and take this in our script as something that looks like this we'll have some matrix and 40 00:02:54,030 --> 00:02:56,560 then we specify which rose we want. 41 00:02:56,750 --> 00:03:00,760 If a comma and then we specify specify which columns we want. 42 00:03:01,050 --> 00:03:04,320 So it goes Rose comma column within the square brackets. 43 00:03:04,320 --> 00:03:09,930 And if you want all the rows or all the columns you're just going to go ahead and leave that blank. 44 00:03:09,960 --> 00:03:13,980 So let's go ahead and see what else we can do here. 45 00:03:13,980 --> 00:03:18,140 Imagine you wanted to grab the first three rows of a matrix. 46 00:03:18,260 --> 00:03:23,160 Well we would just say Matrix name but the square brackets in there. 47 00:03:23,160 --> 00:03:26,280 And here we can use this slicing notation. 48 00:03:26,280 --> 00:03:33,120 So one colon three that's going to return 1 2 and 3 for the rows and then I'm going to leave a comma 49 00:03:33,150 --> 00:03:39,750 there because I want all the values for those rows every column value for those three rows and then 50 00:03:39,750 --> 00:03:44,700 we can see that it gets returned those three rows for all 10 columns. 51 00:03:44,730 --> 00:03:46,060 All right great. 52 00:03:46,080 --> 00:03:51,650 So let's go ahead and take a look at our matrix one more time. 53 00:03:51,840 --> 00:03:53,560 So we have this matrix Matt. 54 00:03:54,030 --> 00:03:57,110 It's 10 columns by five rows. 55 00:03:57,120 --> 00:04:02,930 Imagine I want it to grab let's say just the top left right rectangle So that's going to be let's say 56 00:04:02,950 --> 00:04:07,140 just want to grab one two three and 11 12 13. 57 00:04:07,190 --> 00:04:08,780 I would actually do that. 58 00:04:08,880 --> 00:04:12,510 So I'm going to say Matt square brackets. 59 00:04:12,660 --> 00:04:15,540 I want to go ahead and grab that left top left rectangle. 60 00:04:15,600 --> 00:04:18,570 So it's going to be looks like the first two rows. 61 00:04:18,590 --> 00:04:21,730 So it's I want one two three and 11 12 13. 62 00:04:21,900 --> 00:04:23,560 So gonna go ahead and put in the first two rows. 63 00:04:23,550 --> 00:04:27,450 So that's one goal and two for that slice of the first two rows. 64 00:04:27,780 --> 00:04:30,520 And I also want the first three columns. 65 00:04:30,540 --> 00:04:31,560 One two three. 66 00:04:31,560 --> 00:04:34,420 So that's going to be one comma three. 67 00:04:35,700 --> 00:04:36,420 And there you have it. 68 00:04:36,420 --> 00:04:39,780 We have that rectangle back that top left rectangle. 69 00:04:40,320 --> 00:04:44,640 OK let's go ahead and just show two more quick examples. 70 00:04:44,640 --> 00:04:47,410 Imagine I wanted to grab the last two columns. 71 00:04:47,670 --> 00:04:51,270 I could do Matt since I want just columns. 72 00:04:51,270 --> 00:04:53,070 That means I want all the rows for it. 73 00:04:53,080 --> 00:04:57,600 So going to put a comma and I'm going to go to specify columns 9 through 10. 74 00:04:57,600 --> 00:04:59,380 So those are the last two columns. 75 00:04:59,760 --> 00:05:00,600 And there you have it. 76 00:05:00,600 --> 00:05:02,870 We have the last two columns there. 77 00:05:02,970 --> 00:05:05,710 Let's show one more example of this. 78 00:05:05,820 --> 00:05:08,390 Go ahead and see what the map looks like. 79 00:05:08,400 --> 00:05:11,310 Imagine you want it to grab let's say just a center square. 80 00:05:11,310 --> 00:05:15,200 So I want 15 16 and 25 26. 81 00:05:15,240 --> 00:05:23,100 I want this square in the matrix when I go ahead and say mats and let's see we're going to need the 82 00:05:23,100 --> 00:05:31,560 rows for 15 16 25 26 will need two and three are going to go and slice rows two for three comma. 83 00:05:31,620 --> 00:05:36,240 Then I'm going to do the columns in this case looks like it's five through six and you can notice. 84 00:05:36,240 --> 00:05:42,230 Now hopefully this notation starts to make sense as to why our studios are reporting it as blank. 85 00:05:42,240 --> 00:05:46,460 Comma 5 because this stands for all the rows in column 5. 86 00:05:46,500 --> 00:05:48,560 Likewise for the rows. 87 00:05:48,570 --> 00:05:52,780 It's going to be the row comma blank because it's all the columns for the first row. 88 00:05:52,800 --> 00:05:59,400 So if I go ahead and run this it returns back that square from the Matrix. 89 00:05:59,400 --> 00:06:00,060 OK. 90 00:06:00,240 --> 00:06:05,020 So that's it as far as the general syntax for grabbing chunks from the Matrix. 91 00:06:05,140 --> 00:06:10,950 But I encourage you to do is just go ahead and pick out with your eyes some gen's rectangles or rows 92 00:06:10,950 --> 00:06:15,540 or columns from our general matrix here and see if you can index them correctly. 93 00:06:15,630 --> 00:06:22,290 So maybe try grabbing the rectangle here 33 through 35 and 43 for 45. 94 00:06:22,290 --> 00:06:23,780 See if you can grab that rectangle. 95 00:06:23,790 --> 00:06:24,930 How would you do it. 96 00:06:24,950 --> 00:06:26,230 Just go ahead and practice. 97 00:06:26,280 --> 00:06:30,240 Choose some rectangles or squares in the matrix and see if you can index them out. 98 00:06:30,600 --> 00:06:31,500 OK. 99 00:06:31,500 --> 00:06:33,860 Thanks everyone and I'll see you at the next lecture. 9877

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.