Your code is correct: the 'for' loop makes a copy of the first column of matrix a. Is it that what you wanted to do? You have to realize that the variable b is not defined, so when you write b(i) it automatically creates a variable b of length i. Usually, if you know the size of your feature matrix, you should preallocate the space. For example, if you know that your b will end up being matrix 5x1, then it would be grammatically correct to write
this should save calculation time (for large matrices). Currently your variable 'b' is rewritten each loop (the row becomes longer by one element each loop). If you just want to read a specific element from the matrix 'a', just do b=a(3,2); which will give you the element of the third row, second column. The reason you get a value of the last row when you call for b(i), is because after the loop is finished, the value of 'i' is 5, and thus you call for b(5).