sum(j == I) is counting the number of entries in I that are equal to 1, 2, 3, ... 15322. The "if" around it is an implicit test for non-zero, so it is testing to see if there are any entries at all that match. A better way would be
if any(j == I)
I would suggest, though, that you would probably be better off using
[tf, idx] = ismember(x, I);
for j = idx ...
and probably you would be better off yet inverting the search, like ismember(I, x)
first thing is, how would you define a middle element in a 10*10 array.
Sum(i=1 to 10)Sum(j=1 to 10){I(i,j)-I(m)}*H(i,j)}
Btw, look at the above statement carefully, what you are doing is nothing but multiplying corresponding elements of 2 matrices and then summing up all the elements.you can accomplish this by:
Best Answer