Matrix in matlab

broken image

A of I comma colon means we are indexing into all of the columns in row I, which in this case is row 2. Then inside the loop, I'll write the following command: A of I comma colon equals A of I minus 1 comma colon plus 1, and then end. I'll go ahead and create an index variable for i equals 2 through 5. So this means we're going to need four iterations in the loop.

broken image

We know that we need to append four rows to our current vector. So now that we have our vector, we need to think about creating our matrix in a loop.

broken image

And I'll show you why at the end of the video. I'm not going to suppress the outputs in this example. So now that we found the pattern, the question is, how do we create this matrix in a loop? Well, the first step is going to be to create the initial vector. And the second column reads 3, 4, 5, 6, 7, et cetera, et cetera. See, this first column reads 1, 2, 3, 4, 5. The values in each row are equal to 1 plus the values above it. If we look closely at this matrix, we can see a pattern. And I want to make the following matrix from it, this one right here. We're going to do this by answering a few questions. Today, we're going to talk about creating a matrix in a loop. Hello, and welcome back to another MATLAB video.

broken image