MATLAB: Integral vector .* sin(pi*x) error matrix dimensions must agree.

f=@(x) um .* sin(lam * x ) % _um vector 1x50 double_

I have the following code I try to find integral for function f the um is data vector (1X50). The problem is how can I used ingtral function to find integral for (vector .* sin(pi*x)), when I run code I received error "matrix dimensions must agree." any badoy can help me.
if true
L=1;
x = linspace(0, L, n);
fm=zeros(1,n);
for i=1:1
lam=i*pi;
f=@(x) um .* sin(lam * x ); % _um vector 1X50 double_
fm=fm+exp(lam^2*T)*sin(lam*x)*(2*integral(f,0,L));
end
end

Best Answer

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