Poll

How can I sort out below problem?

by changing code
0 (0%)
or by changing bit value
0 (0%)

Total Members Voted: 0

Author Topic: Error in a sum  (Read 383 times)

Offline khawajasim

  • Newbie
  • *
  • Posts: 1
  • Matlab Forum
    • View Profile
Error in a sum
« on: August 13, 2011, 02:29:09 PM »
I am writing a code in matlab and dealing with images. I am basically finding the sum of value of each pixel, for this I am using code
 "sum=0;
for i=1:584
    for j=1:40
        img(i,j)
        sum=sum+img(i,j)
    end
end"
here img(i,j) is any gray-scale image. the problem arises here is that the value of "sum" never accedes from 255. Hence I can't get correct value of sum. Someone please help me in finding correct values of sum

Matlab and SimuLink Development Forum

Error in a sum
« on: August 13, 2011, 02:29:09 PM »