Error of Averaging a Large Vector in MATLAB
Error of Averaging a Large Vector in MATLAB How do you accurately take the average of large sets of integers in MATLAB? I have two large vectors (2672x4008 in dimensions) I am dealing with, each the result of pixels in an image. Hence, the resulting vector is filled with values 0 to 256, all integers. My problem is that I want an accurate value of the average intensity of these grey-scale images. To do this, I used the line meanvalue = mean(I(:)) This yielded a value of meanvalue = 155.9335 in the output line of MATLAB. Next, I added 20 to each value of the vector, as below (this should raise the intensity of the overall image, if I am understanding correctly). Ipt = I + 20; I then took the mean value of this new vector, Ipt meanvaluept = mean(Ipt(:)) and matlab spat out a value of meanvaluept = 175.8916. I'm no math wizard, but I know enough to know that 175.8916 - 20 ≠ 155.9335. Any help would be appreciated, either mathematically (how to increase the precision of MATLAB), or pro...