Error generating quadratic mesh

You are not using to code you are showing here, as your code says:

while your code says

You have you added a multiple by 2 here? It does not make sense as you do not have that many cells.