You would need to set N = 8 in the first row of code. If you still have problems, I suggest posting a copy of the actual data as there may be some important detail that your description missed.