filled in missing calculations in matlab file