small error matlab .^ corrected