Hi, I am a newbie and I need to implement following code for 1000 beta value. I can not use nested for loop. I request to you please suggest some method to remove nested for-loop.
%% Start Session
clc;clear all;close all;warning off;tStart = tic;ScoreTolren=-0.25;iterations = 0;SeqInNorm = [];indNorm = 0;SEqNor4Check = [];CheckEntry =0;ExitCondition = 0;MaxItr =0;step = 1/8;IntialLoop = 0;for beta1 = IntialLoop:step:1 for beta2 = IntialLoop:step:1-beta1 for beta3 = IntialLoop:step:1-beta1-beta2 for beta4 = IntialLoop:step:1-beta1-beta2-beta3 for beta5 = IntialLoop:step:1-beta1-beta2-beta3-beta4 for beta6 = IntialLoop:step:1-beta1-beta2-beta3-beta4-beta5 for beta7 = IntialLoop:step:1-beta1-beta2-beta3-beta4-beta5-beta6 for beta8 = IntialLoop:step:1-beta1-beta2-beta3-beta4-beta5-beta6-beta7 for beta9 = IntialLoop:step:1-beta1-beta2-beta3-beta4-beta5-beta6-beta7-beta8 for beta10 = IntialLoop:step:1-beta1-beta2-beta3-beta4-beta5-beta6-beta7-beta8-beta9 for beta11 = IntialLoop:step:1-beta1-beta2-beta3-beta4-beta5-beta6-beta7-beta8-beta9-beta10 for beta12 = IntialLoop:step:1-beta1-beta2-beta3-beta4-beta5-beta6-beta7-beta8-beta9-beta10-beta11 for beta13 = IntialLoop:step:1-beta1-beta2-beta3-beta4-beta5-beta6-beta7-beta8-beta9-beta10-beta11-beta12 for beta14 = IntialLoop:step:1-beta1-beta2-beta3-beta4-beta5-beta6-beta7-beta8-beta9-beta10-beta11-beta12-beta13 for beta15 = IntialLoop:step:1-beta1-beta2-beta3-beta4-beta5-beta6-beta7-beta8-beta9-beta10-beta11-beta12-beta13-beta14 beta16 = 1-beta1-beta2-beta3-beta4-beta5-beta6-beta7-beta8-beta9-beta10-beta11-beta12-beta13-beta14-beta15; iterations = iterations+1; b(iterations,:)= [beta1,beta2,beta3,beta4,beta5,beta6,beta7,beta8,beta9,beta10,beta11,beta12,beta13,beta14,beta15,beta16]; if iterations == 1e5 ExitCondition = 1; break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; end end if ExitCondition == 1 break; endend%% End of iteration
elapsedTime = toc(tStart);
Best Answer