Creating a nested loop
Show older comments
Suppose I want to generate a 2 x 9 matrix by looping the following code twice
for j = 1:size(Mdl_vol,2)
EstMdl = estimate(Mdl_vol(j),IVOLI(:,1),'Display','off');
results = summarize(EstMdl);
AIC(j) = results.AIC;
BIC(j) = results.BIC;
end
I tried this;
for i = 3:4
for j = 1:size(Mdl_vol,2)
EstMdl = estimate(Mdl_vol(j),IVOLI(:,i),'Display','off');
results = summarize(EstMdl);
AIC(i,j) = results.AIC;
BIC(i,j) = results.BIC;
end
end
but it gives me a 4x9 matrix for some reason
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!