Index in position 2 exceeds array bounds (must not exceed 5).

1 回表示 (過去 30 日間)
Maksim Gridchin
Maksim Gridchin 2020 年 1 月 15 日
編集済み: KALYAN ACHARJYA 2020 年 1 月 15 日
function boiling_point
clc
for i = 1:5
u0 = [1; 1; 1; 1; 1; 1; 100];
[u] = fsolve(@nl_eq, u0);
fprintf(1,' %d tbp = %g C.\n',i, u(6+i));
end
end
function sol = nl_eq(u,i)
sol = zeros(7);
x = [0.1 0.2 0.2 0.2 0.2;
0.2 0.1 0.2 0.2 0.2;
0.2 0.2 0.1 0.2 0.2;
0.2 0.2 0.2 0.1 0.2;
0.2 0.2 0.2 0.2 0.1;
0.1 0.1 0.1 0.1 0.1];
A = [-3843 -4002 -4997 -5595 -6301 -7296];
B = [8.358 7.833 8.665 8.847 9.261 10.078];
Ci = 460;
for i=1:6
sol(i) = A(i)/(u(7)+Ci)+B(i)-log(u(i));
end
sol(7) = sum(u(1:6).*x(:,i))-1;
end
I know what does this error mean, but I can't understand what element is out of dimension. Appreciate any help!

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 1 月 15 日
編集済み: KALYAN ACHARJYA 2020 年 1 月 15 日
I sense to be here
fprintf(1,' %d tbp = %g C.\n',i, u(6+i));
%...................................^
Check?
>>whos u

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by