MATLAB: Error: Matrix dimensions must agree

error

code:
x=linspace(-5,5,1000);
n=double(1:1:100);
l=2;
f=sin(x);
g=cos(x);
s=0;
landa=((n*pi)/l );
a=(2/l)*int(f.*sin((n*pi)/l)*x,0,l);
b=(2/(l*landa))*int(g*sin((n*pi*x)/l,0,l));
for n=1:1:1000
p=((a*cos(landa*t)+ b*sin(landa*t))*sin((n*pi*x)/l));
s=s + p;
end
plot (x,t,s)

Best Answer

syms x n
% n=double(1:1:100);
l=2;
f=sin(x);
g=cos(x);
s=0;
landa=((n*pi)/l );
a=(2/l)*int(f*sin((n*pi)/l)*x,0,l);
b=(2/(l*landa))*int(g*sin((n*pi*x)/l),0,1);
Related Question