Index in position 1 exceeds array bounds. Index must not exceed 1.
3 次查看(过去 30 天)
显示 更早的评论
Need some help on the coding. Please and Thanks!
3 个评论
KSSV
2022-1-17
Told is a scalar i.e. it is a constant and you are trying to extract second element element from it. So error pops out. You need to intialize Told into a matrix and fill some values into it.
回答(1 个)
per isakson
2022-1-17
编辑:per isakson
2022-1-17
What is your intention with this assignment?
%% Initial condition
T(:,:) = 293; % initial temperature (K)
Matlab makes T a scalar.
In the first iteration
Told = T;
assigns this scalar to Told
In the first iteration the failing statement
T(j,k)=(Told(j,k)*(1-r1-r2)+dt*D...
references Told(2,2), which throws the error.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!