Index exceeds number of array elements (1)

I continue to get the error "index exceeds number of array elements (1)" regarding the first line of this for loop,
Q_out2=dt*((A(T_night-T_out))/R);
I don't unerstand why because I am not trying to create a vector or matrix on either side. Help?
i=1;
for dt=1:n:7
Q_out2=dt*((A(T_night-T_out))/R);
dT=(Q_out2)/(ctm*mt);
T_current2(i)=T_night-dT;
if T_current2(i)<T_night
Q_furnace2=dt((A*(T_night-T_current2(i)))/R);
if Q_furnace2>30000
Q_furnace2=30000;
end
end
i=i+1;
end

 採用された回答

Adam Danz
Adam Danz 2019 年 3 月 12 日
編集済み: Adam Danz 2019 年 3 月 25 日

0 投票

We can't run your code because we don't have values of n, dt, A, and so on. But based on the information you provided, (T_night - T_out) produces a value that is not equal to 1 and your variable "A" only has 1 element.
Here's an example that reproduces the same error.
A = {42};
T_night = 10;
T_out = 2;
A(T_night-T_out)
% ERROR: Index exceeds array bounds.
If that doesn't solve your problem, you could provide the values of "A" and "T_night - T_out" to get more help.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

質問済み:

2019 年 3 月 12 日

編集済み:

2019 年 3 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by