# How do you calculate the electric field from conduction and/or valence band energy?

I am currently using a program to calculate the band diagram of a semiconductor structure in 3D. I am wondering if its possible to use the finite difference method to calculate the electric field. This would mean:

$$\frac{\partial Ec}{\partial x} = \frac{Ec(n+1)-Ec(n-1)}{x(n+1)-x(n-1)}$$

Would this work?