The matrices you created "manually" using the range variables can be created automatically using CreateMesh. Your definition of z() could be simply theata (w/o cos) and apply a range from 0 to height.
But ist fine you finally found what you were looking for.