When in doubt, and if you do not intend matrix operations, vectorise every operation to do element-wise operations. Specifying'ArrayValued',true in theintegral call is also necessary here.
Try this:
fm = fm + exp(lam^2*T).*sin(lam*x).*(2*integral(f,0,L, 'ArrayValued',1));
Best Answer