I have attached a ZIP file which contains the following:
phasedArray.m - script for estimating phased array
locations.mat - 3D locations of each element
singleElementGain - beam pattern of one element
mmpolar - a great file for plotting radiation patterns correctly
I threw in some old data so that you can see how I formatted everything. The script should be fully operational right now. I always find it easier to edit code that works when I start, rather than a chunk of code that doesn't actually do anything.
Let me know how it goes!