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

2 visualizaciones (últimos 30 días)
Victoria Rodriguez
Victoria Rodriguez el 21 de Abr. de 2022
Editada: Jon el 21 de Abr. de 2022
Error is occuring in my delta2_new variable, line 6 in this portion of my code. Unsure how to fix it and get my code running.
while error > epsilon
alpha = (3/10) - (lambda/120);
beta = (37/315) - (lambda/945) - ((lambda^2)/9072);
gamma = 2 + (lambda/6);
u0(i) = (h1*U) / (h1 - ((x*(h1-h2))/L) - ((alpha*delta2_old)/beta));
delta2_new = sqrt( ((d2(i-1)^2) + (2*v*(beta*gamma)/u0(i))*(delta_x)) / (1 + (2*(2 + (alpha/beta))) * ((u0(i) - u0(i-1))/u0(i))) );
tau(i) = (beta/gamma) * ((mu*u0(i)) / delta2_new);
delta = delta2_new / beta;
delta1(i) = alpha*beta;
error = abs((delta2_new - delta2_old)/delta2_new);
delta2_old = delta2_new;
end
  2 comentarios
Jon
Jon el 21 de Abr. de 2022
Editada: Jon el 21 de Abr. de 2022
It's hard to tell what is going on here with the subscripts. Can you please also provide the code where your variable i and other variables d2, u0, etc are assigned
Torsten
Torsten el 21 de Abr. de 2022
Please post executable code. With this incomplete code, nothing can be said concerning your error.
And it would help if you explain in a few words what you are trying to do.

Iniciar sesión para comentar.

Respuestas (1)

David Hill
David Hill el 21 de Abr. de 2022
What is i?
delta2_new = sqrt( ((d2(i-1)^2) + (2*v*(beta*gamma)/u0(i))*(delta_x)) / (1 + (2*(2 + (alpha/beta))) * ((u0(i) - u0(i-1))/u0(i))) );
%you are indexing into a variable (i=2) that only has one element. Check
%the sizes of all your variables (u0, d2). u0 is likely your problem.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by