error: Matrix dimensions must agree

1 Ansicht (letzte 30 Tage)
HADIMARGO
HADIMARGO am 14 Dez. 2018
Kommentiert: Walter Roberson am 20 Dez. 2018
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)
  2 Kommentare
KSSV
KSSV am 14 Dez. 2018
a=(2/l)*int(f.*sin((n*pi)/l)*x,0,l);
In the above f,x is 1*1000 and n is 1*100..you cannot mulitply them....rethink on your code.
Walter Roberson
Walter Roberson am 20 Dez. 2018
please do not close questions that have an answer

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

KSSV
KSSV am 14 Dez. 2018
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);

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by