How do you choose the heights of a terrain using code?

I really need this as I want to make a procedurally generated terrain so are there any way of specifying that the [x,z] position’s height in the terrain height data is going to be equal to 4, for example.

Note - I already have a noise generator and know how to set it up with everything else for the world generation process, I just need to know how to change the height of the terrain using code.¨

It’s so I can create something like this, just without textures so far:

You can set heights of a terrain using a matrix of floats with Unity - Scripting API: TerrainData.SetHeights