[This line](https://github.com/sandialabs/MATLAB_PV_LIB/blob/684553ac1d21c59752240295ef225af7ccc1ca82/pvl_extraradiation.m#L28) should be ``` B = 2*pi*(doy - 1)/365; ``` As described in the [original source](https://www.mail-archive.com/sundial@uni-koeln.de/msg01050.html), the day of year runs between 0 and 364.