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

1 次查看(过去 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