I have two input files T and dispatch_seq. My code looks at T and sees how many rows of dispatch_seq should be taken. The result is stored in Output.
load T.mat load dispatch_seq.mat for j = 1:length(T) ph1 = cumsum(cell2mat(dispatch_seq{j}(:,2))); DecR1 = 10*rem(ph1,1); for k = 1:length(ph1) if DecR1(k) <= 0.1 ph1(k) = round(ph1(k)); end end j_1 = find(ph1>=T(j),1); Output(j) = {dispatch_seq{j}(1:j_1,:)}; if ph1(j_1) > T(j) Output{j}{end,2} = (Output{j}{end,2}-ph1(j_1)+T(j)); end end
Everything works as expected with the exception of Output{28,1} and Output{77,1}. What happens there is the number in the corresponding row of the vector T equals exactly the sum of all rows of dispatch_seq, but the result I get in Output is []. How can I avoid this error?
Best Answer