C is a mxn cell of objects of class A. Class A have the method f(). Then, I have these lines of code
sum=0;
for i=1:m
for j=1:n
a=C{i,j};
sum=sum +a.f();
end
end
It seems that using the for loop will make the code run slowly. Is there any way, like using some kinds of matrix of objects, or something like that, for the better performance of this code?
What about using cellfun ?
http://www.mathworks.com/help/techdoc/ref/cellfun.html