I tested your script and did not find anything wrong:

Please make sure that your file is 3D and no ay error massage shows before line 9.
The error message showig from above means the matrix has something wrong. Please check the dimension of E2.
You may also need to reboot your computer, modify the simulation settings if necessay, redo the simulation and run the script.