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

조회 수: 3 (최근 30일)
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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by