Index exceeds the number of array elements (1) Issue
1 次查看(过去 30 天)
显示 更早的评论
I keep getting the error "Index exceeds the number of array elements (1)". The error starts at the line with NX1=. I have no idea how to fix this. The goal is to iterate n and m values to find when NX1 is at a minimum
D = zeros(3,3);
D = D + 1/3*Qbar0*(z(2)^3-z(1)^3);
D = D + 1/3*Qbar0*(z(3)^3-z(2)^3);
D = D + 1/3*Qbar90*(z(4)^3-z(3)^3);
D = D + 1/3*Qbar90*(z(5)^3-z(4)^3);
D = D + 1/3*Qbar0*(z(6)^3-z(5)^3);
D = D + 1/3*Qbar0*(z(7)^3-z(6)^3);
R1 = 0;
for n = 1:10
for m = 1:10;
Nx1(n,m) = (pi^2) * ((D(1,1)*(m/a)^2 + 2*(D(1,2) + 2*D(3,3))*(n/b)^2 + D(2,2)*(n/b)^4 * (a/m)^2)/ (1 + R1((a/b * n/m)^2)))
end
end
min(min(Nx1))
3 个评论
回答(1 个)
Théophane Dimier
2020-12-4
Have you checked if Nx1 is not already existing before the for loop? It might be that it already exists and that it is a scalar. A hint could be to clear the workspace at the beginning of the code. Anyway, you can trigger "Pause on error" (click on the small arrow under the "Run" button). It will pause the execution right before the error, then launch the code and when it stops, look at the list of variable to check if Nx1 is not just a scalar.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!