The array is long enough, still gets Array Index out of bound error.
Show older comments
I have a structure array named AnalysisResult. Each of the structure have three elements.
- width which is a 216 x 2 x 14 Matrix,
- width_mean which is a 1 x 14 vector
- width_std which is a 1 x 14 vector
when I run the following code
function [acrossAxisRadiusVariation,acrossAxisMeanVariation] = calculateVariationAcrossAxis(AnalysisResult,circleNo,angleNo)
ss=size(AnalysisResult,2);
acrossAxisRadiusVariation=zeros(ss,1);
for counter=1:ss
acrossAxisRadiusVariation(counter,:)=AnalysisResult(counter).width(angleNo,2,circleNo);
acrossAxisMeanVariation(counter,:)=AnalysisResult(counter).width_mean(circleNo);
end
end
If my structure have 100 around elements, with circleNo =13 and angleNo = 54 it works fine. but if I run for circleNo=14. It gives me following error.
Attempted to access AnalysisResult.width(54,2,14); index out of bounds because size(AnalysisResult.width)=[126,2,13].
Error in calculateVariationAcrossAxis (line 7)
acrossAxisRadiusVariation(counter,:)=AnalysisResult(counter).width(angleNo,2,circleNo);
But on command window I am able to access AnalysisResult(1).width(54,2,14).
If my structure have 700 elements then the similar problem occurs for circleNo 8 and above.
Is this something to do with the size of the parameters.
I am not able to figure out.
2 Comments
Put this in your loop:
for counter=1:ss
disp(size(AnalysisResult(counter).width))
... etc
end
and tell us what is displays just before the error occurs.
shaleen jain
on 10 Aug 2016
Answers (0)
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!