필터 지우기
필터 지우기

My 'For' sequence is giving me "Array indices must be positive integers or logical values."

조회 수: 1 (최근 30일)
This is my code, can you tell me whats wrong with it, please?
a = 1;
pi = 3.14159265359;
b = (540/2)/1000; %mm
rho = 8960; %kg/m3
c = 385; % J/(K·kg)
k = 400; % W/(K·m)
alpha = k/(rho*c);
y = input('y = ');
t = input('t=');
for i= 0:100
x =((-1)^a(i))/((a(i)+(1/2))*pi)*e^(-(a(i)+(1/2))^2*pi^2*alpha*t/b^2)*cos(a(i)+(1/2))*pi*y/b
x1 = 2*x
end
  댓글 수: 2
per isakson
per isakson 2018년 5월 7일
편집: per isakson 2018년 5월 7일
Replace
for i= 0:100
by
for ii = 0:100
i = ii - 1;
And pi is already defined in Matlab
Arantxa Abascal
Arantxa Abascal 2018년 5월 7일
Thanks, but it's still not working, i think there's something else wrong.

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

채택된 답변

Siyu Guo
Siyu Guo 2018년 5월 7일
Array index in MATLAB starts from 1 instead of 0.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by