"Index exceeds the number of array elements. Index must not exceed 1."

2 ビュー (過去 30 日間)
Victoria Rodriguez
Victoria Rodriguez 2022 年 4 月 13 日
コメント済み: Victoria Rodriguez 2022 年 4 月 13 日
Beginner coder here. I'm trying to run my code and I've got an index error. I don't know how to fix it. I have a bunch of variables assigned to number values, so I left those out, but I know my error is stemming from this loop. Again, I don't know how to fix it.
Any help would be greatly appreiciated
for i=2:nx
error=1;
x=x+delta_x;
delta2_old = delta2(i-1);
while error > epsilon
alpha = (3/10) - (lambda/120);
beta = (37/315) - (lambda/945) - ((lambda^2)/9072);
gamma = 2 + (lambda/6);
u0 = (h1*U) / (h1 - ((x*(h1-h2))/L) - ((alpha*delta2_old)/beta));
delta2_new = sqrt( ((d2^2) + (2*v*(beta*gamma)/u0)*delta_x) / (1 + (2*(2 + (alpha/beta))) * ((u0 - u_0)/u0)) );
error = abs((delta2_new - delta2_old)/delta2_new);
u0_old = u0_new;
delta2_old = delta2_new;
end
delta2(i)= delta2_new;
delta1(i)= (alpha*delta2(i))/beta;
tau(i)= beta*gamma*((mu*u0(i))/delta2(i));
xv(i)=x;
iv(i)=i;
end

採用された回答

Torsten
Torsten 2022 年 4 月 13 日
tau(i)= beta*gamma*((mu*u0)/delta2(i));
instead of
tau(i)= beta*gamma*((mu*u0(i))/delta2(i));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by