Here is a heavily commented version of the logistical map code that I showed you. Matlab syntax for definition of a function starts with the word "function" and then there are square brackets around the stuff that you want that function to return. followed by an equal sign. Then there is the function name and in parentheses the arguments to this function. The sqaure brackets in matlab are how you define a vector. Down here in the command window I'm defining the row vector. It has three elements. 1,2,3 so this line right here the first line of the program is setting up a vector that has no elements in it and I'm setting that up so I can stuff the iterates of the logistic map into that. On line 5, I'm setting up an internal variable to store the current iterate and I'm setting it's value to the inital condition that was passed to the function. Then we go into the loop that produces the end iterates that were required of this function. In matlab, you don't specify the beginning and endpoints of the index of a loop. Rather, you give the for loop the a vector containing the values you wanted it to index. In this particular case I'm making a vector that starts at zero and goes up to N. Let me show you how that works. By default the spacing in the vector is one. If you want to change that you can. By doing something like this So, this for loop is going to get executed for the index value 0,1,2,3,4,5,6 and on up to N. And, what the guys of the for loop do are two things. First, this line right here. It takes all the iterates you have computed so far, sticks the current iterate onto the tail end of it makes a new vector out of that and replaces the old value in the list of iterates you produced so far with that new augmented value let me show you how that works. Here, I'm making self a row vector called foo. That has four elements by the way the semi colon in matlab supresses output. So if I were to do that same assignment value to foo and put a semi colon afterword. It would do it. It just wouldn't tell me that it did it. That's why there are all these semi-colons up here. If I didn't have those matlab would be telling me everything it did as it ran that function. Let's say I want to stick another number onto the tail end of foo. I would do it like this and that returns that vector. Now, notice that I did not set that as the new value of foo. So, if I just look at what's in foo. I see what was there before. But I can set that value to the new value like so. And now what's in foo. Is that vector with the new value on the end. The right hand side of the last line of code inside the for loop is evaluating the logistic map for the current value of X. Then it is replacing the contents of that variable With that new calculation, that is the updated calculation and then it loops.