I'm getting the following error once in like 50 times : In an assignment A(:) = B, the number of elements in A and B must be the same. Error in WMTC_2 (line 272) pos(i)=find(rand<=cumsum(mt_carr),1,'first');
while t_sum<=t_final-tf_idle ctr3=ctr3+1; vf_sum=0; vf_bef=vf_ave; i=i+1; pos(i)=find(rand<cumsum(mt_carr),1,'first'); pos_mt(i)=find(rand<cumsum(mt_arr(:,pos(i))),1,'first'); t_sum=t_sum+mt_cat1(pos(i)).mtc(pos_mt(i)).t; tbef_sum=t_sum; zz=i; for z=1:i vf_sum=vf_sum+mt_cat1(pos(z)).mtc(pos_mt(z)).vm_ave; end vf_ave=vf_sum/i; if vf_bef<vp_ave %if the average of current set of chosen mts is more or less than prelim. target, choose the next mt so as to decrease or increase the net ave speed respectively
if mt_cat1(pos(i)).mtc(pos_mt(i)).vm_ave<v_ave t_sum=t_sum-mt_cat1(pos(i)).mtc(pos_mt(i)).t; i=i-1; ctr6=ctr6+1; end else %vf_bef>vp_ave
if mt_cat1(pos(i)).mtc(pos_mt(i)).vm_ave>v_ave t_sum=t_sum-mt_cat1(pos(i)).mtc(pos_mt(i)).t; i=i-1; ctr7=ctr7+1; end end end
Best Answer