what is the error Matrix dimensions must agree.?

조회 수: 1 (최근 30일)
HADIMARGO
HADIMARGO 2018년 12월 16일
편집: James Tursa 2018년 12월 18일
code:
clc
clear all;
x=linspace(-10,10,1000);
t=0:1:20;
k=10;
l=10;
u_x=2*k*x/l.*(x>0 & x<l/2)+2*k*(1-x)/l.*(x>l/2 & x<l/2);
plot(x,u_x)
s=0;
for n=1:1:1000
s=s+(1/n.^2).*sin(n.*pi/2).*cos(n.*pi.*t/l).*sin(n.*pi.*x/l);
end
u_x_t=(8*k/pi^2)*s;
................................................
error:
Matrix dimensions must agree.
Error in Untitled (line 16)
s=s+(1/n.^2).*sin(n.*pi/2).*cos(n.*pi.*t/l).*sin(n.*pi.*x/l);
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 12월 18일
Please do not close questions that have an answer.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 12월 16일
t is length 21. cos n pi t over l will be length 21
x is length 1000. sin n pi x over l will be length 1000
you are trying to .* those two together . What is your expectations about the size of the results ?

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by