First, you should predefine the size of u instead of changing the size throughout your script.
Second, in the first for loop you have written
But x is not defined, did you mean to use the variable a as input? Why do you even need a loop, the following should be fine (assuming u is predefined)
When I run your code I do not get the "Index exceeds matrix dimensions" error but instead I get an error because the number of rows in u is not equal to the number of values in a. Because you did not predefine the size of u the size will be 81*81 and the vector a will have length 120.